-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding translation of network object to/from networkx
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import networkx as nx | ||
|
||
def to_networkx( | ||
net: "NetworkBase", | ||
node_attr: list[str] = None, | ||
edge_attr: list[str] = None) -> nx.Graph: | ||
netx = nx.Graph() | ||
return netx | ||
|
||
|
||
def from_networkx(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
import networkx as nx | ||
from networkcommons.network._formats._networkx import to_networkx | ||
from networkcommons.network._network import NetworkBase | ||
|
||
@pytest.fixture | ||
def small_network(): | ||
nodes = ['A', 'B', 'C'] | ||
edges = [('A', 'B'), ('B', 'C')] | ||
network = NetworkBase(edges = edges, nodes = nodes) | ||
return network | ||
|
||
|
||
def test_to_networkx(small_network): | ||
#create a networkbase object | ||
#convert it to networkx | ||
netx = to_networkx(small_network) | ||
assert isinstance(netx, nx.Graph) |