Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graphviz: Create new node with this same label

Tags:

graphviz

I'm starting working with graphviz and I have problem with creating new nodes with this same label. For example for word "sentence" I would like to create graph with 8 nodes: s -> e -> n -> t -> e -> n -> c -> e Now I'm receiving graph with only 5 nodes (one "e" instead of 3 and one "n" instead of 2). I need to create more nodes with this same label (value).

Example of my problem may be this image http://rdftwig.sourceforge.net/paper/diagrams/bfsdeep.png where there are 2 nodes with value "C", "E" and "D".

Is it possible? If it is possible how can I access in my example with word "sentence" first, second or third "e" node?

like image 590
Piotr0123456 Avatar asked May 14 '12 07:05

Piotr0123456


1 Answers

You could define your nodes explicitly and set the label for them. Then each node has an unique id, but can have the same labels. Consider this example:

strict graph G {
    1 [label="A"];
    2 [label="B"];
    3 [label="B"];
    4 [label="A"];
    1 -- 2;
    2 -- 3;
    3 -- 4;
}

which will output (with dot):

Nodes with same labels

like image 104
Maehler Avatar answered Oct 21 '22 11:10

Maehler