diff --git a/networkcommons/network/_formats/__init__.py b/networkcommons/network/_formats/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/networkcommons/network/_formats/_networkx.py b/networkcommons/network/_formats/_networkx.py new file mode 100644 index 0000000..339c901 --- /dev/null +++ b/networkcommons/network/_formats/_networkx.py @@ -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 \ No newline at end of file diff --git a/tests/test_formats.py b/tests/test_formats.py new file mode 100644 index 0000000..89781d5 --- /dev/null +++ b/tests/test_formats.py @@ -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)