Help with .dot code for Graphviz

  • Context: Python 
  • Thread starter Thread starter UFSJ
  • Start date Start date
  • Tags Tags
    Code
Click For Summary

Discussion Overview

The discussion revolves around creating a network graph using dot code for Graphviz, specifically focusing on visualizing approximately 1500 nodes with geographic coordinates and bounded connections. Participants explore various approaches to achieve the desired graphical representation, including the use of external tools and programming languages.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • The original poster (OP) seeks assistance with dot code to create a network graph with specific visual characteristics, including node size, color, and lack of labels.
  • One participant suggests that while the desired output can be achieved with Graphviz, the documentation can be challenging, and recommends starting with a similar example and modifying it.
  • Another participant questions whether the OP prefers a diagram that overlays on a map using external software like Photoshop, or a fully automated solution that integrates mapping directly into the graph generation process.
  • A later reply mentions that combining Graphviz output with a map image can be done easily on Linux using ImageMagick's composite command in a script.

Areas of Agreement / Disagreement

Participants express different views on whether to pursue a fully automated solution or to use external tools for overlaying graphs on maps. There is no consensus on the best approach to take for the OP's requirements.

Contextual Notes

Participants mention the complexity of handling a large number of nodes and the potential need for additional programming to generate the .dot file. The discussion also highlights the limitations of Graphviz documentation.

UFSJ
Messages
13
Reaction score
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).

[CODE lang="python" title="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 ;
}[/CODE]

I thanks a lot by any kind of help.
 
Technology news on Phys.org
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)?

[CODE lang="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
a -- d
}
[/CODE]
 
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.
 
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   Reactions: FactChecker

Similar threads

  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 31 ·
2
Replies
31
Views
7K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K