3

何か足りないのでしょうか、それとも Gephi スクリプト コンソールの奇妙なバグですか?

コンソールにはエッジが表示されますが、ノードは表示されません

例えば

>>> len(g.edges)
4314
>>> len(g.nodes)
1

>>> g.edges
set([e8926, e8794, e7024 ......])
>>> g.nodes
set([None])

Gephi で提供されるデータセットPower Grid.gmlを使用して、エラーを再現できます。たとえば、 here のいくつかのデータセットでこれをテストしたところ、同じエラーが発生しました。

私は何か間違っていますか?

4

3 に答える 3

3

「Data Table」という名前のプラグインがあります。インストールすると、データセットの構造を確認できます。私はまさにそのような問題を抱えていて、ノードIDが数字ではなく文字列であることを理解しました。スクリプト プラグインの違いを確認したい場合は、コンソール スクリプト プラグインで g.nodes() コマンドを実行すると、(「データ テーブル」プラグインから) 新しく作成されたノードの ID が文字列ではなく数値であることがわかります。Gephi コンソールで g.nodes または len(g.nodes) を実行すると、新しく作成されたノードが表示されます。私はこの方法でそれを解決します:「データテーブル」という名前のプラグインをインストールし、「テーブルをエクスポート」できます。それを選択すると、エクスポートする必要がある列がわかります。 OKを押すと保存されます。新しいプロジェクトを作成し、「データ テーブル」プラグインを開き、「

于 2013-04-05T06:40:33.240 に答える
1

元の質問から 2 年経った今でも、バグは Gephi の Jython コンソールのどこかに残っています。

>>> g.nodes
set([None])

ただし、次のようにスクリプト コンソールを介してノードを直接操作する回避策を見つけました。

>>> graph = g.getUnderlyingGraph()
>>> nodes = [node for node in graph.nodes]
>>> nodes
[n0, n1, n2, n3, n4, n5, n6, n7, ...

これを行うことで、次のようにノード属性を操作できました。

>>> node = nodes[0]
>>> attr = node.attributes
>>> value = attr.getValue('attribute_name')
>>> new_value = do_something(value)
>>> attr.setValue('attribute_name', new_value)
于 2015-04-09T12:52:16.200 に答える
0

user1290329がここで行ったことを行った後、エッジを元の位置に戻すのに問題がある場合に備えて、Pythonで作成したスクリプトを次に示します[ https://stackoverflow.com/a/15827459/1645451]

これは基本的に、gephi で作成された新しい整数 Id 列をエッジ テーブルにマップします。

    import pandas as pd

    # Once you have re-imported your CSV, and your ID is an Int, 
    # but your edge table is still messed up
    nodes = pd.read_csv('nodes_table.csv')
    edges = pd.read_csv('edges_table.csv')

    # delete any unnecessary cols
    del edges['Label']


    # Create a dictionary with your Node name as the key, 
    # and its Gephi int Id as the value
    # To do this Set index to be col you want the dict keys to be
    # and the dict values will be col you specifiy in the brackets after 'ie ['Id']
    node_dict = nodes.set_index('Label')['Id'].to_dict()

    # Then use the map function, col you are mapping with should have they keys
    # And will fill with value of key when matched
    # In this case we just over-write the Source and Target cols
    edges['Source'] = edges['Source'].map(node_dict)
    edges['Target'] = edges['Target'].map(node_dict)

    edges.to_csv('edges_formatted_for_gephi.csv', index=False)
    edges.head()

ここで、gephi データ ラボでスプレッドシートをインポートし、edges オプションを選択していることを確認し、「edges_formatted_for_gephi.csv」をクリックして選択し、欠けているノードの作成のチェックを外すと、gephi グラフにエッジが戻るはずです。:)

于 2014-10-18T20:34:35.083 に答える