pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

[FEA] highlight pattern matches and submatches

Open lmeyerov opened this issue 3 years ago • 0 comments
trafficstars

Is your feature request related to a problem? Please describe.

When looking at a graph, want to highlight some paths, such as by a search

Currently, we can search g.chain(...) or g._nodes.query(...) but hard to then superimpose back: g.nodes(g._nodes.merge(g2._nodes, how='left', ...))

Describe the solution you'd like

g.chain([n(name=...), ...], mode='enrich', name='p1')

This:

  • returns the original graph rather than a subgraph
  • labels every node, edge with p1=True if its a match
  • ... default: match=True or first free (match_1, match-2, ...)
  • for any named node/edge predicate, also set that column

Ideally this can be done multiple times and ~OR's vs overrides on named matches:

g.chain(.., mode='enrich').chain(..., mode='enrich').encode_point_colors('match').plot()

Describe alternatives you've considered

It may be also interesting to do something like g1.enrich(g2, name='match', node_cols=['name'], edge_cols=[...]) as a rough compositional equivalent

Additional context

Came up in a context where multiple such ^^^ were used

lmeyerov avatar Oct 13 '22 19:10 lmeyerov