如何在.dot文件中设置节点的大小?

时间:2012-07-11 19:34:26

标签: graph-theory dot gephi

我想设置节点的大小相对于它们在图形中的影响,我需要找到一些方法让它们的大小出现在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中时,节点的大小都相同。我错过了什么吗?

1 个答案:

答案 0 :(得分: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];

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