# How to Edit a graph somewhere else in the file

I need to edit a digraph elsewhere in the same file to add node and connections
any help?

/**
* \dot
* digraph State_Machine_Example {
* node [shape=record, fontname=Helvetica, fontsize=10];
* 0 [ label="state 0"];
* 1 [ label="state 1"];
* 0 -> 1 [ arrowhead="open", style="dashed" ];
* }
* \enddot
*/


After that in the same file I need to add nodes and connections

/**
* \dot
* digraph State_Machine_Example {
* 2 [ label="state 2"];
* 1 -> 2 [ arrowhead="open", style="dashed" ];
* }
* \enddot
*/


I do not understand your question, but maybe we can get to common ground:

• What you are showing is not valid Graphviz input. It seems to be valid Graphviz wrapped in C, C++ (or similar) comments. Why? Is this to be input to some other program that will, in turn, remove the comment characters & feed it to a Graphviz program?
• Is your goal to produce 1 graph, 2 graphs, or more? Normally, the Graphviz layout engines can only take one graph as input (and therefore as output). Some of the auxillary programs (e.g gvpack) can take multiple input graphs and combine them.

Can you explain what you mean by “edit”? Normally you would just use any text editor to alter your dot source. But I’m guessing you need to do something more complicated.

By the way, you can use triple backticks with dot as the source language to paste Graphviz source directly instead of wrapping it in C-style quotes.