Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpedigo committed May 28, 2024
1 parent a6e66ac commit c3c54a5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions networkframe/networkframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ def __init__(
referenced_node_ids = np.union1d(
edges["source"].unique(), edges["target"].unique()
)
# TODO fix this very very slow check
if not np.all(np.isin(referenced_node_ids, nodes.index)):
raise ValueError(
"All nodes referenced in `edges` must be in `nodes` index."
)

# should probably assume things like "source" and "target" columns
# should probably assume things li
# ke "source" and "target" columns
# and that these elements are in the nodes dataframe
# TODO are multigraphs allowed?
# TODO assert that sources and targets and node index are all unique?
Expand Down Expand Up @@ -589,7 +591,11 @@ def to_networkx(
return g

def to_sparse_adjacency(
self, weight_col: Optional[str] = None, aggfunc="sum", verify_integrity=True
self,
weight_col: Optional[str] = None,
aggfunc="sum",
verify_integrity=True,
format="csr",
) -> csr_array:
"""
Return the [adjacency matrix](https://en.wikipedia.org/wiki/Adjacency_matrix)
Expand Down Expand Up @@ -659,7 +665,15 @@ def to_sparse_adjacency(
(data, (source_indices.codes, target_indices.codes)),
shape=(len(self.sources), len(self.targets)),
)

if format == "lil":
from scipy.sparse import lil_array

adj = lil_array(adj)
return adj

def to_torch_geometric(self):
pass

def _get_component_indices(
self, directed: bool = True, connection: ConnectionType = "weak"
Expand Down Expand Up @@ -1321,7 +1335,6 @@ def k_hop_aggregation(
columns will be the aggregated features (with f'_neighbor_{agg}' appended
to each column name).
"""


if isinstance(aggregations, str):
aggregations = [aggregations]
Expand Down

0 comments on commit c3c54a5

Please sign in to comment.