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.

Consistent interface for (directed) graph creation

See original GitHub issue

This toy example suggests a problem with our current approach to creating graphs:

In [13]: A = np.array([[0,1,0],[1,0,1],[0,0,0]])                                                                                                                                               

In [14]: A                                                                                                                                                                                     
Out[14]: 
array([[0, 1, 0],
       [1, 0, 1],
       [0, 0, 0]])

In [15]: import networkx as nx                                                                                                                                                                 

In [16]: G = nx.from_numpy_array(A)                                                                                                                                                            

In [17]: G.is_directed()                                                                                                                                                                       
Out[17]: False

It seems that if we have an asymmetric matrix we need to be explicit about using the nx.DiGraph constructor.

A utility function for determining which graph constructor to use (and performing other potentially useful preprocessing, like removing self-loops) would probably be useful here.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sdmccabecommented, Jan 22, 2019

Making explicit a conversation with @leotrs: I’m not sure that from_numpy_array strictly requires networkx 2.2, but the arguments I’m passing to the create_using parameter follow a style used in 2.2. If need be, I suspect we can rewrite some things to be 2.0-compatible, but for the sake of simplicity let’s just bump the requirements for now. (Networkx 2.3 will be out soon anyway.)

0reactions
sdmccabecommented, Jan 22, 2019

@jkbren @tlarock Note that now that this is merged it might affect the distance heatmaps. Let me know if something has dramatically changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing a New Interface for Directed Graph Analysis by ...
Abstract. We have developed a multiplatform application that provides an easy-to- use alternative for structural analysis of directed graphs.
Read more >
4.2 Directed Graphs - Algorithms, 4th Edition
A directed graph (or digraph) is a set of vertices and a collection of directed edges that each connects an ordered pair of...
Read more >
Using directed graphs to define viewpoints to keep a ...
Viewpoints need to define consistency rules. ... The work presented in this article shows that directed graphs can be used to define ...
Read more >
GraphsExplained · google/guava Wiki - GitHub
A graph is directed if each of its edges are directed, and undirected if each of its edges are undirected. ( common. graph...
Read more >
Meta-modeling game for deriving theory-consistent ...
We first review the directed graph approach that enables us to generate and utilize a decision tree to represent the modeling process (Section...
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