Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to visualize graph in PyQt GUI program?

I am working on a community detection GUI program in PyQt5. In a section of my program I want to visualize a network (Graph) which I have found its communities.
When i run the program in non-GUI way everything is OK and the graph is visualized in the browser but when i put the code in GUI again everything runs correctly and the program ends with no errors, but the graph is not shown in the browser.
I appreciate any help on this problem.
The code below shows how i visualize the graph. coms.communities is the communities which i have found using CDLIB library and nodes_list holds the label of each node. I aimed to color the nodes in same community with same color and because of that i use the labeles of nodes to give them same color.

            palette = (sns.color_palette("Pastel1", n_colors=len(coms.communities))) 
            palette = palette.as_hex()
            colorDict = {}
            counter = 0
            for i in palette:
                colorDict[counter] = i
                counter += 1
            N = Network(height='100%', width='100%', directed=False, notebook=False)
            for n in G.nodes:
                N.add_node(n, color=(colorDict[nodes_list[n]]), size=5)

            for e in G.edges.data():
                N.add_edge(e[0], e[1])
            N.show('result.html')

Everything is OK with code but i don’t know how to use this code in a GUI program to show the constructed graph in a browser.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As the code shows everything is OK and i tested your code and it works correctly. Make sure that you have not put any other code such as return ... before this code because it ends the program at that line and does not allow the program to continue your visualization code

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading