Hi,
it seems due to changes to the networkx pacakge, GraphEmbed no longer works.
I'm on Python 2.7.17 and networkx 2.1.
I used the provided example files and first ran into this error (I've edited out some parts of the file paths):
Traceback (most recent call last):
File "./graph_embed.py", line 405, in <module>
main(args)
File "./graph_embed.py", line 354, in main
data_matrix_2d = ge.transform(data_matrix=data_matrix, target=y)
File "../GraphEmbed/graph_layout_embedder.py", line 114, in transform
random_state=self.random_state)
File "../miniconda3/envs/py27/lib/python2.7/site-packages/toolz/functoolz.py", line 440, in memof
cache[k] = result = func(*args, **kwargs)
File "../GraphEmbed/graph_layout_embedder.py", line 324, in annotate_graph_with_graphviz_layout
layout_pos = nx.graphviz_layout(graph)
AttributeError: 'module' object has no attribute 'graphviz_layout'
This can be solved by editing graph_layout_embedder.py:
- Add an addtional import:
from networkx.drawing.nx_agraph import graphviz_layout
- Change line 323 from:
layout_pos = nx.graphviz_layout(graph)
to
layout_pos = nx.drawing.nx_agraph.graphviz_layout(graph)
After that, a second error popped up:
Traceback (most recent call last):
File "./graph_embed.py", line 405, in <module>
main(args)
File "./graph_embed.py", line 377, in main
figure_size=figure_size)
File "../GraphEmbed/graph_layout_embedder.py", line 447, in display_hull
save_figure=save_figure)
File "../GraphEmbed/graph_layout_embedder.py", line 616, in display_graph
cmap=cmap)
File "../GraphEmbed/graph_layout_embedder.py", line 668, in _display_class
for i, j in average_graph.edges()]
AttributeError: 'Graph' object has no attribute 'edge'
Changing line 667 in graph_layout_embedder.py from
widths = [average_graph.edge[i][j]['width'] * 20
to
widths = [average_graph[i][j]['width'] * 20
fixed this.
I'm not too well versed in Python, so I don't know if these are the best fixes for the errors.
Hi,
it seems due to changes to the networkx pacakge, GraphEmbed no longer works.
I'm on Python 2.7.17 and networkx 2.1.
I used the provided example files and first ran into this error (I've edited out some parts of the file paths):
This can be solved by editing
graph_layout_embedder.py:from networkx.drawing.nx_agraph import graphviz_layoutlayout_pos = nx.graphviz_layout(graph)to
layout_pos = nx.drawing.nx_agraph.graphviz_layout(graph)After that, a second error popped up:
Changing line 667 in
graph_layout_embedder.pyfromwidths = [average_graph.edge[i][j]['width'] * 20to
widths = [average_graph[i][j]['width'] * 20fixed this.
I'm not too well versed in Python, so I don't know if these are the best fixes for the errors.