43

For my application I need to represent simultaneously (on the same graph) two relations: one is simmetric, the other is not.

Targets:

  • Ideally the two relation should result in edges having different colors;
  • For the symmetric relation I would like not to have double-edges;

Is there a way of doing this with dot?

Dacav
  • 13,590
  • 11
  • 60
  • 87

2 Answers2

55
digraph {

    A; B; C

    subgraph Rel1 {
        edge [dir=none, color=red]
        A -> B -> C -> A
    }

    subgraph Rel2 {
        edge [color=blue]

        B -> C
        C -> A
    }

}

enter image description here

Dacav
  • 13,590
  • 11
  • 60
  • 87
  • 2
    Does anybody know simpler solution of combining gigraph with graph? – user1742529 Oct 10 '19 at 08:49
  • @user1742529 Not sure what you mean, there’s no such combination happening here. Possibly you’re confused by the word “subgraph”; that’s just basic compartmentalization, a way of saying THESE lines should be blue and THOSE lines should be orange. – Frungi Jan 12 '21 at 04:07
  • @Frungi, sorry. I mean: simpler solution for combining "digraph" with "graph"? ( https://graphviz.readthedocs.io/en/stable/api.html#graphviz.Digraph ) – user1742529 Jan 17 '21 at 16:17
14

You can pass dir=none as an edge property to the undirected graph connections:

digraph {

    A; B; C
    
    A -> B
    B -> C
    C -> A [dir=none]
}

enter image description here

Daniel
  • 11,332
  • 9
  • 44
  • 72