holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.7k stars 402 forks source link

Cannot use bipartite_layout with hv.Graph.from_networkx #3100

Open dsludwig opened 6 years ago

dsludwig commented 6 years ago

The nodes argument to from_networkx shadows the nodes argument to bipartite_layout, so the keyword argument is not forwarded to the layout function.

http://holoviews.org/Reference_Manual/holoviews.element.html#holoviews.element.Graph.from_networkx

classmethod from_networkx ( G , layout_function , nodes=None , **kwargs )

https://networkx.github.io/documentation/latest/reference/generated/networkx.drawing.layout.bipartite_layout.html

bipartite_layout(G, nodes, align='vertical', scale=1, center=None, aspect_ratio=1.3333333333333333)

philippjfr commented 5 years ago

As a workaround it is possible to use the layout_nodes operation:

G = nx.bipartite.gnmk_random_graph(3, 5, 10, seed=123)
top = nx.bipartite.sets(G)[0]
graph = hv.Graph.from_networkx(G, layout_function=nx.circular_layout)
hv.element.graphs.layout_nodes(graph, layout=nx.layout.bipartite_layout, kwargs={'nodes': top})