Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for writing graphml files from nx dialect #40

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added `grand.DiGraph` convenience wrapper for directed graphs
- Dialects
- Expanded Networkit dialect test coverage
- Added support for exporting NetworkX graphs by adding `graph` attribute

## **0.4.2** (May 7, 2022)

Expand Down
4 changes: 4 additions & 0 deletions grand/dialects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def _pred(self):
"""
return _GrandAdjacencyView(self, "pred")

@property
def graph(self):
return {}

def in_degree(self, nbunch=None):
return self.parent.backend.in_degrees(nbunch)

Expand Down
6 changes: 6 additions & 0 deletions grand/dialects/test_dialect.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import unittest

from .. import Graph
Expand Down Expand Up @@ -89,6 +90,11 @@ def test_nx_edges(self):
self.assertEqual(dict(G.edges()), dict(H.edges()))
self.assertEqual(list(G.edges["1", "2"]), list(H.edges["1", "2"]))

def test_nx_export(self):
gg = Graph()
f = io.BytesIO()
nx.write_graphml(gg.nx, f)


class TestNetworkitDialect(unittest.TestCase):
def test_add_verts(self):
Expand Down