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

Improved Graph element #2145

Merged
merged 5 commits into from Nov 23, 2017

Conversation

Projects
None yet
2 participants
@philippjfr
Member

philippjfr commented Nov 23, 2017

Since I started writing the Chord (#2138) and TriMesh (#2143) elements, it's become clear that the Graph element is quite useful as a baseclass for other elements. However currently it isn't as solid, optimized and tested as I'd like it to be, so rather than mixing up a bunch of changes into the Chord and TriMesh PRs I've decided to first build on Graph, ensuring that it is well tested and solid at it's core.

This will improve Graphs in a number of ways:

Graph Element Improvements

  1. Add an optimized pandas based implementation that handles drawing direct edge paths between nodes. The naive implementation relying just on HoloViews functionality is way to slow and this provides a ~100x speedup as long as pandas is installed.
  2. Graphs allowed supplying node information without defining the explicit node positions. This code was brittle and relied on implicit assumptions on the ordering of nodes. I've hardened the exception handling here, being much stricter about how node information is merged and relying on pandas to handle actual merges between node indices.

Graph Plot improvements

  1. The Graph glyphs are now updated in a well defined order, which ensures that explicit paths are re-rendered correctly when updated.
  2. The GraphPlot implementations now support an edge_color_index allowing them to be colored both by categorical attributes (e.g. by their source node) or by a value (e.g. a weight value).
  • Added tests
  • Added documentation

@philippjfr philippjfr added the plotting label Nov 23, 2017

N = len(nodes)
circ = np.pi/N*np.arange(N)*2
x = np.cos(circ)
y = np.sin(circ)
return (x, y, nodes)
def connect_edges_pd(graph):

This comment has been minimized.

@jlstevens

jlstevens Nov 23, 2017

Member

Maybe move some of these functions to element.util?

This comment has been minimized.

@philippjfr

philippjfr Nov 23, 2017

Member

Yes, sounds good.

@@ -411,6 +412,59 @@ def map_colors(arr, crange, cmap, hex=True):
return arr
def mplcmap_to_palette(cmap, ncolors=None):

This comment has been minimized.

@jlstevens

jlstevens Nov 23, 2017

Member

Seems like the right place for these utilities!

g = self.graph4.opts(plot=dict(edge_color_index='Weight'),
style=dict(edge_cmap=['#FFFFFF', '#000000']))
plot = bokeh_renderer.get_plot(g)
print(plot.handles)

This comment has been minimized.

@jlstevens

jlstevens Nov 23, 2017

Member

Stray print.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Nov 23, 2017

Looks good! Other than some very minor comments I posted above, I am happy for you to go ahead and merge once you think it is ready.

@philippjfr

This comment has been minimized.

Member

philippjfr commented Nov 23, 2017

Yay, even got a gain in coverage. Thanks for the review, merging.

@philippjfr philippjfr merged commit 4c1b01d into master Nov 23, 2017

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.04%) to 81.132%
Details
s3-reference-data-cache Test data is cached.
Details

@philippjfr philippjfr added this to the v1.9.2 milestone Dec 8, 2017

@pyup-bot pyup-bot referenced this pull request Dec 12, 2017

Merged

Update holoviews to 1.9.2 #139

@philippjfr philippjfr deleted the graph_enhancements branch Dec 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment