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.

Dynamic (?) graph supporting ??

See original GitHub issue

Hi, I’m a big fan of DGL and always use it for my GNN projects.

I wonder what will be a friendly DGL practice for handling dynamic (?) graphs. It might be good to start with my own definition of a dynamic graph. Hereby, I mean dynamic graph is the graph whose edge connectivity can differ based on the node features.

Such a concept of the graph can be found quite frequently while building models for solving PDEs or simulating physics simulators. One particular case is Learning to Simulate Complex Physics with Graph Networks, where the graphs are required to be constructed when two particles (nodes) are close to each other.

I realized that, as far as I know, in DGL it will not be easy to implement the edges which are added/deleted based on the node features. So, what will be the most DGL way to implement the idea in this kind of scenario? I guess we can confront quite a similar issue when we handle the set data also.

My hack for implementing such graph computation was to construct a complete graph and mask the messages depending on the node features, which is not computationally efficient.

[1] Learning to Simulate Complex Physics with Graph Networks - http://proceedings.mlr.press/v119/sanchez-gonzalez20a/sanchez-gonzalez20a.pdf

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BarclayIIcommented, Aug 26, 2021

I see. I would rather do something like:

coords = torch.randn(n_nodes, 2)
connections = torch.cdist(coords, coords) < radius
src, dst = connections.nonzero(as_tuple=True)
graph = dgl.graph((src, dst), num_nodes=n_nodes)

This should be more efficient than the one above since cdist should be more efficient than apply_edges due to dense computation, and nonzero() is also more efficient than remove_edges because the latter are hashtable lookups.

0reactions
Junyoungparkcommented, Aug 25, 2021

Thanks for helping me out! This discussion was a great chance to better understand DGL ops.

Since now this thread is considered to be “feature request”. It might be even better to consider the option ignore_self for ignoring particle itself.

coords = torch.randn(n_nodes, 2)
connections = torch.cdist(coords, coords) < radius
if ignore_self:
    connections = connections.long() - torch.diag(torch.ones(n_nodes))
src, dst = connections.nonzero(as_tuple=True)
graph = dgl.graph((src, dst), num_nodes=n_nodes)

I believe such feature can be done like above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Graph | TouchGFX Documentation
A Dynamic Graph in TouchGFX is a widget that allows an application to display data points on a monotonous x-axis. The Dynamic Graph...
Read more >
JavaScript Live / Dynamic Charts & Graphs - CanvasJS.com
Dynamic Chart are also known as Real Time charts. Dynamic updates are supported by all chart types including line, area, column, bar, pie,...
Read more >
Dynamic Graphs - JanusGraph Docs
JanusGraph supports dynamically creating graphs. This is deviation from the way in which standard Gremlin Server implementations allow one to access a graph...
Read more >
cuSTINGER: Supporting dynamic graph algorithms for GPUs
cuSTINGER, a new graph data structure targeting NVIDIA GPUs is designed for streaming graphs that evolve over time. cuSTINGER enables algorithm designers ...
Read more >
Excel Dynamic Charts Based On Dynamic Arrays - 2515
Brand new in Excel Insiders Beta:A chart can be based on an entire dynamic array in Excel.In this first iteration, the chart has...
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