Skip to content
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

G wants to be symmetric? #5

Open
wolfiex opened this issue Oct 23, 2018 · 2 comments
Open

G wants to be symmetric? #5

wolfiex opened this issue Oct 23, 2018 · 2 comments

Comments

@wolfiex
Copy link

wolfiex commented Oct 23, 2018

 line 110, in force_atlas2_layout
    assert numpy.all(G.T == G), "G is not symmetric."
AssertionError: G is not symmetric
@NMertsch
Copy link

NMertsch commented May 9, 2019

Maybe a bit late, but Force Atlas 2 is a algorithm for undirected graphs. This means that every edge from node1 to node2 has a equal edge from node2 to node1 (-> edges have no direction).

This implies that G, the weight matrix of the graph, is symmetric: The entry G[node1, node2] of that matrix contains the weight for the edge node1->node2. For undirected graphs this implies that the edge node2->node1 has the same weight, so G[node1, node2] == G[node2, node1] has to be True for every entry in G (0 means "no edge").

The line of code you mentions means exactly that: It checks if G is symmetric and raises the AssertionError if the check fails.

In short: The weight matrix of your graph is not symmetric, so your graph is not undirected, so Force Atlas 2 can not help you here.

If you are sure that the graph is undirected, maybe it is a floating point precision error (like 1 != 1.000000000001).

@wolfiex
Copy link
Author

wolfiex commented May 14, 2019

A good compromise of the code would then be to take the abs net edge weight in creation of a symmetric graph. That would replace the assertion error with a simple warning, allowing the code to run for all usercases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants