question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi!

I want to highlight edges after user input via some widgets. For this I defined a CSS class like:

#...
{
  "selector": "edge.highlighted",
  "css": {
    "line-color": "red"
  }
},
#....

I then have some widgets for input and also a cell which looks like this:

widget = ipycytoscape.CytoscapeWidget()
widget.set_style(precgraph_jupyterutil.graph_css)
widget.graph.add_graph_from_networkx(some_networkx_graph, directed=True)

btn = widgets.Button(description="apply", icon="check", disabled=False)

def btn_callback(b):
  for edge in widget.graph.edges:
    classes = set(edge.classes.split(" "))
    classes.add("highlighted")
    edge.classes = " ".join(classes)

btn.on_click(callback=btn_callback)
display(btn)

widget

However I cannot get the graph to update interactively. It renders at the beginning as it should, but updating the classes attribute has no effect. I also cannot find any update function or similar.

I verified that it works at all by adding another cell after the one posted above with:

widget

If I run this cell I can see the graph with all edges in red (which verifies that the CSS etc works as expected).

What is the intended way to update the visualization? I would really appreciate any help 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
marimeirelescommented, Jun 24, 2020

Unfortunately that’s exactly how it’s working. This is what we have for the current code, every time you make a change the whole graph is rerendered. I opened an issue so we could discuss solutions about that #105

0reactions
christiandrehercommented, Jun 24, 2020

Hi @marimeireles, awesome, thank you very much for the quick fix. I installed ipycytoscape via pip, so I think I’ll just wait for the release. Until then the quickfix works.

One question though, does this now trigger a redraw for each changed class? Because I planned to iterate over all edges and adjust the classes, which would be quite wasteful if it would be redrawn in each loop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edge Highlighting Is Easier to Learn Than You Think (Tutorial)
Learning how to do edge highlighting can be a bit intimidating. However, it really is easy to learn and I'll show you how...
Read more >
Highlight nodes and edges in plotted graph - MATLAB highlight
Isolated nodes with degree 0 are not highlighted. highlight( H , s,t ) highlights all edges between the specified source and target ...
Read more >
HighlightEdges - Maple Help - Maplesoft
The command HighlightEdges, marks the specified edges to be rendered with the default highlighted style. •. Given only a graph G and an...
Read more >
More highlights - The Army Painter
How to edge highlight · Add a drop of water to your Warpaints. · The key to precise edge highlights is using the...
Read more >
Highlight an edge in a graphviz generated svg - gists · GitHub
Highlight an edge in a graphviz generated svg. GitHub Gist: instantly share code, notes, and snippets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found