最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

graphviz - Fixed position in the first column for the nodes, not in the others - Stack Overflow

programmeradmin1浏览0评论

I want a table of 2 columns with graphviz. Within the first columns I would like to have fixed positions for the nodes (x and Y). The other nodes can be freely positioned by graphviz within the assigned (other) column, i.e. the Y position does not matter. The positions within the first columns should not change, regardless of the connections to the nodes in the other columns

    digraph G {
      rankdir=LR;
      node [shape=box];
      
      subgraph cluster_0 {
        label = "Spalte 1";
        a [pos="0,2!"];
        b [pos="0,1!"];
        c [pos="0,0!"];
      }
    
      subgraph cluster_1 {
        label = "Spalte 2";
        d;
        e;
        f;
      }
    
  a-> e;
  a -> f;
    
    }

Currently the column slides up instead of the nodes within the column. Just change a-> to somethig to see it.

I want a table of 2 columns with graphviz. Within the first columns I would like to have fixed positions for the nodes (x and Y). The other nodes can be freely positioned by graphviz within the assigned (other) column, i.e. the Y position does not matter. The positions within the first columns should not change, regardless of the connections to the nodes in the other columns

    digraph G {
      rankdir=LR;
      node [shape=box];
      
      subgraph cluster_0 {
        label = "Spalte 1";
        a [pos="0,2!"];
        b [pos="0,1!"];
        c [pos="0,0!"];
      }
    
      subgraph cluster_1 {
        label = "Spalte 2";
        d;
        e;
        f;
      }
    
  a-> e;
  a -> f;
    
    }

Currently the column slides up instead of the nodes within the column. Just change a-> to somethig to see it.

Share Improve this question edited Nov 18, 2024 at 19:11 eshirvana 24.7k3 gold badges27 silver badges42 bronze badges asked Nov 18, 2024 at 19:10 ozzozz 1831 silver badge13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

packmode (https://www.graphviz./docs/attr-types/packMode/) seems to accomplish your goal.
Note that nodes are in first-in-last-out order.

digraph G {
      rankdir=LR;
      packmode="array_ic2"  // the two clusters must not be connected (no edges)
      // packmode works best with recent (~2024 and later) releases of Graphviz
      node [shape=box];
      
      subgraph cluster_0 {
        label = "Spalte 1";
        a [pos="0,2!"];  // fyi, dot ignores all pos attributes
        b [pos="0,1!"];
        c [pos="0,0!"];
      }
    
      subgraph cluster_1 {
        label = "Spalte 2";
        d;
        e;
        f;
      }
    
// packmode requires no edges between the clusters to be "packed"
//  a-> e;  
//  a -> f;
    
    }

Giving:

发布评论

评论列表(0)

  1. 暂无评论