【问题标题】:How do I set the size of a node in a .dot file?如何在 .dot 文件中设置节点的大小?
【发布时间】:2012-07-30 15:02:05
【问题描述】:

我想根据节点在图表中的影响来设置节点的大小,我需要找到一些方法让它们的大小出现在 Gephi 中。目前,我正在使用以下代码:

def write_graph_dot(graph, filename, label=None):
    g = AGraph(directed=True)
    nodes = set()
    for key in graph:
        if key not in nodes:
            nodes.add(key)
            g.add_node(key, color='red')
            node = g.get_node(key)
            node.attr['fixedsize'] = True
            node.attr['height'] = 1.0
            node.attr['width'] = 1.0
        for value in graph[key]:
            if value not in nodes:
                nodes.add(value)
                g.add_node(key, color='black')
            g.add_edge(key, value, color='black')
    g.write(filename)

但是,当我将它加载到 Gephi 中时,节点的大小都相同。我错过了什么吗?

【问题讨论】:

    标签: graph-theory dot gephi


    【解决方案1】:

    这是不可能的。

    Subgraphs are not supported, nor custom attributes or size. Only labels and colors are imported if present. Directed and undirected graphs are supported.
    

    https://gephi.org/users/supported-graph-formats/graphviz-dot-format/

    但你可以将“size”作为变量导入,然后在gephi中使用它来设置大小:

     a [label="Foo"];
     a [mysize = 100];
    

    (您必须先将导入的变量从字符串转换为整数。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-27
      • 2021-10-06
      • 1970-01-01
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      • 2018-05-30
      • 2019-10-04
      相关资源
      最近更新 更多