Giter Site home page Giter Site logo

qgraphviz's Introduction

QGraphViz

A PyQT based GraphViz builder/renderer (100% opensource)

Introduction

I was searching for a handy tool to code graphs using python then visualize them within my software. I found about graphviz which is a great tool to build graphs.

The problem is that you need to install the graphviz software in order to compile your file and render it.

There is a graphviz package on PYPI that allows creating dot code that can then be processed by graphviz, but in practice, you need to install graphviz and somehow add it to your path in order to execute the render command.

PyGraphviz is another package that can be used. But as you can read in their documentation, you still need to install Graphviz.

I also found this visualizer based on pyQt4. It is a simple Qt based visualizer that tracks the updates on the .gv file and redraws it in realtime: DDorch/GraphVizLiveUpdateViewer

So since I didn't find any package out there that satifies my needs, I decided to create a pyQT5 based Graphviz tool that can visualize Graphviz code without the need to install Graphviz and provide it with MIT licence, so that other people can simply use it in their software.

Objective

Build python pyQT5 based QWidget that can visualize graphs and allow realtime interaction with graphs add edges and nodes, change attributes ...

Requirements

As its name suggests, this module needs you to install pyqt5 package first.

pip install pyqt5

Installation

pip install QGraphViz

Actual status

  1. Simple graphs visualization (nodes + edges)
  2. Simple gv files read/write
  3. Graph nodes can hold custom parameters that can be used by the application
  4. Graph nodes are now manipulable and we can add nodes and link them using the QWidget gui, wa can also delete nodes.
  5. The application can accept or refuse edges creation and even add custom parameters to the edges
  6. The nodes can be double clicked and an event is sent to the application allowing it to do custom
  7. User application is informed wen a new connection is created between two nodes, when a node is selected or when it is double clicked.
  8. User application is informed when a edge is selected or double clicked.
  9. Only two supported node shapes (box or oval)
  10. Advanced nodes shapes are not yet implemented
  11. Only the dot layout is implemented
  12. Supported shapes are box, circle, triangle, diamond, polygon
  13. Supported custom node shapes using png images

Example code

You can find an example code for manipulating graphs in examples/QGraphViewer.py.

Change log

To view different changes from release to the other please view our changelog.

Warning

If you are aiming to export a .gv file of your graph, don't use images as shapes because this is not supported by real graphviz tool. You can use it safely if you save your graph in our json format.

Special thanks

Here I'll be citing the contributions of others than myself and show them gratitude for help :

  • Many thanks to Ederrod for adding icon shaped nodes.
  • Many thanks to gregori0o for fixing few bugs.
  • Many thanks to ZeJackOfSpades for adding directed graphs option.

If any one has ideas to enhance this tool, you are welcome to contribute.

qgraphviz's People

Contributors

ederrod avatar gregori0o avatar parisneo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

qgraphviz's Issues

Changing Length of Edges

Currently when I generate a large graph, some nodes fall out of the window. If a node goes out of the window I have no way to access it. Is there anyway to resize the graph as a whole or the length of the edges? I saw a parameter to change the width but not one for length. Or additionally is there a way to have the area the graph is generated in be scrollable? I tried putting the widget in a scrollable area but this didn't do anything.

Thanks

Problems with float values and with node resizing

PyQt in my system doesn't cast float to int and I got errors. My proposition is to add hard casting.

The second problem is with node resizing. I set the size of node while creating and the sizes are changed when I clicked on node.

Programmable diagrams.

Is it possible embed a diagram to PyQt5 GUI and change the colour of the edges and nodes dynamically?

Added Node gets sent far off screen

Hello again! When I add a node to graph for some reason it gets sent to the far right way off screen. Do you have any idea why this might be happening? I didn't have this issue before, think it started happening when I updated the package. Thank you for all your help!

Error When Modifying Example

I'm modifying the script in the example folder to add a second subgraph as well as add edges between the nodes in the subgraph, and I'm getting the following image. The nodes I add to the second subgraph seem to overwrite the first subgraph nodes, and when applying an edge to the nodes in the original subgraph one is booted out of the subgraph box (N12 should be inside, and Y subgraph should have nodes in it). I've named and labelled everything differently so I'm not sure why its not working. Any help would be greatly appreciated.

Capture

Here's a snippet of the code for reference. The main differences are the addition of sub_2, n11 and n12, and adding an edge between n11 and n12.

`qgv.setStyleSheet("background-color:white;")
qgv.new(Dot(Graph("Main_Graph"), show_subgraphs=show_subgraphs, font = QFont("Arial", 12),margins=[20,20]))
n1 = qgv.addNode(qgv.engine.graph, "Node1", label="N1", fillcolor="red")
n2 = qgv.addNode(qgv.engine.graph, "Node2", label="N2", fillcolor="blue:white:red")
n3 = qgv.addNode(qgv.engine.graph, "Node3", label="N3", shape = "diamond",fillcolor="orange")
n4 = qgv.addNode(qgv.engine.graph, "Node4", label="N4", shape="diamond",fillcolor="white")
n5 = qgv.addNode(qgv.engine.graph, "Node5", label="N5", shape="polygon", fillcolor="red", color="white")
n6 = qgv.addNode(qgv.engine.graph, "Node6", label="N6", shape="triangle", fillcolor="blue:white:red")

sub = qgv.addSubgraph(qgv.engine.graph, "sub graph", qgv.engine.graph.graph_type, label="y", fillcolor="blue:white:red")
n7 = qgv.addNode(sub, "Node7", label="N7")
n8 = qgv.addNode(sub, "Node8", label="N8")

icon_path = os.path.dirname(os.path.abspath(file)) + r"\icon\dbicon.png,100,100"
n9 = qgv.addNode(qgv.engine.graph, "Node9", label="N9", shape=icon_path)

icon_path = os.path.dirname(os.path.abspath(file)) + r"\icon\cam.png"
n10 = qgv.addNode(qgv.engine.graph, "Node10", label="\n\n\nN10\nTest multilines", shape=icon_path, color="white")

sub_2 = qgv.addSubgraph(qgv.engine.graph, "subgraph2", qgv.engine.graph.graph_type, label="x", fillcolor="blue:white:red")
n11 = qgv.addNode(sub_2, "Node_11", label="N11")
n12 = qgv.addNode(sub_2, "Node_12", label="N12")

qgv.addEdge(n1, n2, {})
qgv.addEdge(n3, n2, {})
qgv.addEdge(n2, n4, {"width":2})
qgv.addEdge(n4, n5, {"width":4})
qgv.addEdge(n4, n6, {"width":5,"color":"red"})
qgv.addEdge(n3, n6, {"width":2})
qgv.addEdge(n6, n9, {"width":5,"color":"red"})
qgv.addEdge(n9, n10, {"width":5,"color":"red"})
qgv.addEdge(n11, n12, {})`

Keep positioning of nodes in json

This is more of a feature request than an issue, but it'd be really cool if the positions of the nodes were saved in the json file as well. The dot engine doesn't create the most readable graphs sometimes. So if the user tweaked the graph manually and was able to save and then load in this updated graph later that'd be awesome. I'll take a look into the API and see if I can tweak it to make this work when I have some time. But thought I'd post this up in case you were already thinking about this or had some time to do it.

Thanks again!

Edges are hard to select

Hello,

I am having Issues to manipulate edges, is there a way to enhance the detection when the mouse is on the edges ?
Mainly when the arrows are in the horizontal positioning

Directed Graph/Nodes

Hello I am looking for directed graph when linking 2 nodes.
Is there a way to have it ?
I have tried to set-up GraphType.DirectedGraph everywhere I can

Thanks in advance for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.