Help with .dot code for Graphviz

  • Python
  • Thread starter UFSJ
  • Start date
  • Tags
    Code
In summary, the conversation is discussing the use of dot code to create a graph using graphviz. The desired graph is a network of 1500 nodes with geographic coordinates and bounded nodes. The output should be similar to a provided example, but with smaller circle nodes, black color, and no labels. The conversation also discusses the possibility of using photoshop to overlay the graph on a map or using a different tool for automation. It is suggested that the first option would require a program to generate a .dot file, while the second option may require a different tool. The solution for combining the graph with a map on Linux is to use imagemagick's composite command in a script.
  • #1
UFSJ
15
2
Hi guys!

I'm completely new with dot code to make graph by graphviz and I'm calling by any help. I would like to make a network of, approximately, 1500 nodes, with each node with its position (geographic coordinate) and its own group of bounded nodes. Some nodes have the same position. These nodes may be represented by points with negligible size and bounded by edges represented by thin lines. I would like to obtain some thing like this: https://tuangauss.github.io/projects/networkx_basemap/networkx_basemap.html , but with an unique size for the circle nodes (smaller than the shown picture), with unique color (black) and without label. Below, I let my code with a reduced number of nodes (just 10 nodes).

My code::
strict graph {
    node [shape = circle size=0.1];
           1  [pos="-61.9961281,-11.9296913!"];
           2  [pos="-63.0330696,-9.90765190!"];
           3  [pos="-63.0330696,-9.90765190!"];
           4  [pos="-61.4420509,-11.4333000!"];
           5  [pos="-61.4420509,-11.4333000!"];
           6  [pos="-60.8168373,-13.1869869!"];
           7  [pos="-60.5454292,-13.1174307!"];
           8  [pos="-64.2279739,-12.4367161!"];
           9  [pos="-61.0130920,-11.5321751!"];
          10  [pos="-65.3327789,-10.7804241!"];
           1 --           4 ;
           1 --           8 ;
           1 --           9 ;
           2 --           3 ;
           2 --           4 ;
           2 --           6 ;
           2 --           7 ;
           2 --           9 ;
           2 --          10 ;
           3 --           4 ;
           3 --           6 ;
           3 --           7 ;
           3 --          10 ;
           4 --           6 ;
           4 --           8 ;
           4 --           9 ;
           4 --          10 ;
           6 --           7 ;
           6 --           9 ;
           6 --          10 ;
           7 --          10 ;
           8 --           9 ;
 }

I thanks a lot by any kind of help.
 
Technology news on Phys.org
  • #2
Well that image uses the Python modules Networx and Basemap, but yoy can do this in graphviz too. The graphviz documentation is not easy to follow and it is always easier to start with something close and amend it. Something like this (follow link for demo)?

Python:
# Using neato engine.

graph {
  graph [bgcolor=lightgray]

  # Default node styles.
  node [style=filled label="" shape=circle width=0.5]

  # Nodes.
  a [width="1" fillcolor="red" pos="0.5,1!" label="⌂"]
  b [fillcolor="blue" pos="0,3!"]
  c [width=0 pos="3,1.5!"]
  d [fillcolor="orange" pos="-1,0!"]

  # Edges.
  a -- b
  a -- c [color="#770077"]
  a -- d
}
 
  • #3
Is it acceptable to make a diagram without the map, but with locations that you can use photoshop to overlay the graph on a map, or do you want a completely automated program? I think that the first option would not be too hard, but an automated program with a map might require a different tool than Graphviz.
With so many nodes, the first option would require a program (Perl, Python, etc.) with the logic to generate a .dot file with the desired commands. The second option might require using a different tool as discussed here.
 
  • #4
The OP is working in linux (see another thread) and it is a simple matter to combine the graphviz output with a map image using imagemagic's composite command in a script.
 
  • Like
Likes FactChecker

1. What is Graphviz and why is it used?

Graphviz is an open-source graph visualization software used to create diagrams and networks. It is often used by scientists, engineers, and data analysts to visually represent complex data and relationships.

2. How do I install Graphviz on my computer?

To install Graphviz, you can visit the official website and download the appropriate version for your operating system. There are also installation guides and tutorials available online to help with the process.

3. What is a .dot file and how do I use it with Graphviz?

A .dot file is a text file that contains the code written in the Graphviz language. This code is used to define the structure and elements of the graph or diagram. To use it with Graphviz, you can either create a new .dot file or modify an existing one using a text editor.

4. Can I customize the appearance of my graph using Graphviz?

Yes, Graphviz offers various customization options such as changing the shape, color, size, and style of the nodes and edges in the graph. You can also add labels, titles, and legends to make your graph more informative and visually appealing.

5. Are there any resources or communities available to help with learning and troubleshooting Graphviz?

Yes, there are various online resources and communities dedicated to Graphviz. The official website offers documentation, tutorials, and forums for users to learn and get support. There are also online communities and forums where you can ask questions and share tips with other Graphviz users.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
3
Views
720
  • Programming and Computer Science
Replies
1
Views
969
  • Programming and Computer Science
Replies
4
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
2
Views
316
  • Programming and Computer Science
Replies
31
Views
6K
  • Programming and Computer Science
Replies
27
Views
2K
Back
Top