Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpedigo committed May 30, 2024
2 parents 99fcb03 + c3c54a5 commit eb200bc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions networkframe/networkframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,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 @@ -588,7 +590,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 @@ -658,7 +664,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 to_torch_geometric(self, directed=True, weight_col=None):
import torch
Expand Down

0 comments on commit eb200bc

Please sign in to comment.