Skip to content

Commit d9c136f

Browse files
committed
Merge pull request #1 from frederik-elwert/feature/graphml
Add GraphML export.
2 parents 56519eb + 638b42b commit d9c136f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

textplot/graphs.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def write_gml(self, path):
5656
nx.readwrite.gml.write_gml(self.graph, path)
5757

5858

59+
def write_graphml(self, path):
60+
61+
"""
62+
Write a GraphML file.
63+
64+
:param path: The file path.
65+
"""
66+
nx.readwrite.graphml.write_graphml(self.graph, path)
67+
68+
5969
class Skimmer(Graph):
6070

6171

@@ -86,4 +96,6 @@ def build(self, matrix, skim_depth=10, d_weights=False):
8696
if d_weights: weight = 1-weight
8797

8898
n2 = matrix.text.unstem(term)
89-
self.graph.add_edge(n1, n2, weight=weight)
99+
# nx does not handle numpy types well when writing graphml,
100+
# so ensure that weight is a regular float.
101+
self.graph.add_edge(n1, n2, weight=float(weight))

0 commit comments

Comments
 (0)