Why doesn't a -- b work but a -> b work?

I just downloaded Graphviz, and I see people posting code like

digraph G {
a -- b;
b -- c;
c -- a;
}

But I get a syntax error when I do this. It only works what I enter

digraph G {
a -> b;
b -> c;
c -> a;
}

But that puts arrows at the end of all the lines, which I don't want.

If you use "graph" rather

If you use "graph" rather than "digraph" to declare the graph, the graph is assumed to have undirected edges and edges are drawn without arrowhead by default. With "graph", you have to use "--" for edge operators; with "digraph", you have to use "->".

So change your graph to

graph G {
a -- b;
b -- c;
c -- a;
}

By the way, the type of graph only determines the default edge style. You can always use the dir attribute to override this.

Recent comments