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

Problem with node attributes (specifically `bipartite') #36

Open
floklimm opened this issue Nov 25, 2019 · 12 comments
Open

Problem with node attributes (specifically `bipartite') #36

floklimm opened this issue Nov 25, 2019 · 12 comments
Labels
bug Something isn't working

Comments

@floklimm
Copy link

floklimm commented Nov 25, 2019

Netwulf seems to have a problem with some node attributes. It results in not plotting anything.

I have a network that is a monopartite projection of a bipartite network. Therefore every node has the attribute ('bipartite',0).

For using Netwulf I have to delete them manually.

for node in tempToPlot:
   del tempToPlot.node[node]['bipartite']

Find attached two input files, one that works and a second one that doesn't work. (I had to rename them as txt)

It might be only the specific node attribute 'bipartite' or node attributes in general. So if people run into this error, just remove the attributes.

matNetwork_error.txt
matNetwork.txt

@benmaier
Copy link
Owner

so the error only occurs after the styling process?

@floklimm
Copy link
Author

floklimm commented Nov 25, 2019

It does occur immediately when executing

wulf.visualize(tempToPlot)  

(and it doesn't throw an error but just an empty canvas, as if you would have input an empty graph)

@benmaier
Copy link
Owner

weird, it works for me. I called

import netwulf as wulf
_, __, G = wulf.load("./matNetwork_error.txt")
wulf.visualize(G)

and I get the following result:

Screen Shot 2019-11-25 at 18 38 17

Which version of netwulf do you have installed? You can find out like this:

print(wulf.__version__)

@benmaier benmaier added the bug Something isn't working label Nov 25, 2019
@benmaier
Copy link
Owner

the current version is 0.1.4. In case you're not on the current version you can update it like this:

pip install --upgrade netwulf

@floklimm
Copy link
Author

I am also on 0.1.4

I will try to create a minimal working example and then report back.

@benmaier
Copy link
Owner

when you said "(and it doesn't throw an error", does that mean you have checked the javascript console for error messages?

@floklimm
Copy link
Author

Please find below a minimal working example:

## import things
import networkx as nx
import netwulf as wulf

## construct a small bipartite network
B = nx.Graph()
nodeSet0 = [1, 2, 3, 4]
B.add_nodes_from(nodeSet0, bipartite=0)
B.add_nodes_from(['a', 'b', 'c'], bipartite=1)
B.add_edges_from([(1, 'a'), (1, 'b'), (2, 'b'), (2, 'c'), (3, 'c'), (4, 'a')])

G=nx.projected_graph(B,nodeSet0)

## visualise the  with netwulf (fails)
wulf.visualize(G)

## removing the `bipartite' node attribute 
copyOfGraph = G.copy()
for node in copyOfGraph:
   del copyOfGraph.node[node]['bipartite']

## Now it works
wulf.visualize(copyOfGraph)

The error message in the javascript console when it fails is
Uncaught TypeError: Cannot read property 'constructor' of undefined
at Xt (sweetalert2.all.min.js:1)
at restart_if_valid_JSON (vis.js:541)
at vis.js:437
at Object. (d3.v4.min.js:7)
at _.call (d3.v4.min.js:4)
at XMLHttpRequest.e (d3.v4.min.js:7)

As removing the node attributes fixes the problem it is not an urgent issue but I thought it should be documented somewhere in case other people run into the same problem.

Versions:
python 3.6.8
networkx 2.2
wulf 0.1.4

I am running it in an Anaconda Jupiter Notebook on a Mac.

@benmaier
Copy link
Owner

which browser?

@benmaier
Copy link
Owner

very weird, your code works on my machine for both python 3.6 and python 3.7 as well as both Chrome and Safari

@benmaier
Copy link
Owner

(thanks for raising the issue though, I heard from several people that they had problems, so this definitely helps)

@floklimm
Copy link
Author

I just checked and the problem seems to occur only with Chrome. Firefox and Safari work without any problem!

@benmaier
Copy link
Owner

weird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants