Graphviz: Invert two nodes position inside a cluster

78 views Asked by At

I am trying to inverse the position of two nodes (producción & funciones) that are inside a cluster (cluster_fp). Instead of producción on top and funciones at bottom, I need funciones on top and producción at bottom. How can I achieve that? They are in a cluster just because I thought it is the right approach, but probably it isn't. Because my reputation, I can't post images directly, so I leave the links to i.stack.imgur.com.

[IMG] Issue (nodes have to be in an inverse vertical position)

Code:

digraph tríada {
  rankdir=LR;
  edge [arrowhead=none];
  label="* socialmente reconocido";
  labeljust=left;

  subgraph cluster_sinonimia_oa {
    style=dashed;
    label="sinonimia obra-texto";

    subgraph cluster_texto {
      style=striped;
      label=texto;

      selección [shape=rect];
    }

    obra [shape=rect, style=striped];
    supuesto [label="supuesto\nexistencial", shape=plain];
  }

  subgraph cluster_autor {
    style=striped;
    label="autor*";
    
    máquinas [shape=hexagon];

    subgraph cluster_fp {
      label="";
      style=invis;

      funciones [label="atribución o\napropiación", shape=plain];
      producción [shape=plain];
    }

    subgraph cluster_sinonimia_nepa {
      style=dashed;
      label="sinonimia nombre-entidad-persona-autor";

      personas [shape=hexagon];
      entidad [shape=rect];
      real [shape=diamond];
      ficticia [shape=diamond];
      nula [shape=diamond];
      denotación [shape=plain];
      nombre [shape=rect];
    }
  }

  {personas máquinas} -> real [arrowhead=normal];
  {real ficticia nula} -> entidad [arrowhead=normal];
  nombre -> funciones -> obra -> supuesto -> selección -> producción -> entidad -> denotación -> nombre;
}

[IMG] Graph image output

Live on dreampuf.github.io

Thanks!

1

There are 1 answers

0
sroush On BEST ANSWER

Based on lots of experiments, the problem seems to be that dot's algorithm "weights" a multi-node edge more than a two-node edge.
Here is a much-edited input file that produces your desired output:

digraph tríada {
  rankdir=LR;
  edge [arrowhead=none];
  label="* socialmente reconocido";
  labeljust=left;

  subgraph cluster_autor {
    style=striped;
    label="autor*";

    subgraph cluster_sinonimia_nepa {
      style=dashed;
      label="sinonimia nombre-entidad-persona-autor";

      personas [shape=hexagon];
      entidad [shape=rect];
      real [shape=diamond];
      ficticia [shape=diamond];
      nula [shape=diamond];
      denotación [shape=plain];
      nombre [shape=rect];
      node [label="" shape=point width=.01] 
      // bogus1 & bogus2 are needed to flip/swap/invert the funciones & producción nodes
      bogus1  bogus2
    }
    
    subgraph cluster_fp {
      label="";
      style=invis;
      funciones [label="atribución o\napropiación", shape=plain];
      producción [shape=plain];
    }

    máquinas [shape=hexagon];

    {personas máquinas} -> real [arrowhead=normal];
    {real ficticia nula} -> entidad [arrowhead=normal];
    entidad -> denotación ->  nombre
  }

  subgraph cluster_sinonimia_oa {
    style=dashed;
    label="sinonimia obra-texto";

    subgraph cluster_texto {
      style=striped;
      label=texto;
      selección [shape=rect];
    }
    obra [shape=rect, style=striped];
    supuesto [label="supuesto\nexistencial", shape=plain];
  }

  nombre -> funciones -> obra -> supuesto -> selección

  producción -> selección  
  entidad -> bogus1 [headclip=false ]
  bogus1 -> bogus2 [tailclip=false, headclip=false]
  bogus2 -> producción [tailclip=false]
}

enter image description here

(Yes, most of the edits were unnecessary)