我有下面的代码来加载数据:
from pymnet import *
import pandas as pd
nodes_id = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 1, 2, 3, 'aa', 'bb', 'cc']
layers = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3]
nodes = {'nodes': nodes_id, 'layers': layers}
df_nodes = pd.DataFrame(nodes)
to = ['b', 'c', 'd', 'f', 1, 2, 3, 'bb', 'cc', 2, 3, 'a', 'g']
from_edges = ['a', 'a', 'b', 'e', 'a', 'b', 'e', 'aa', 'aa', 'aa', 1, 2, 3]
edges = {'to': to, 'from': from_edges}
df_edges = pd.DataFrame(edges)
我正在尝试使用pymnet作为软件包来创建多层网络。 (http://www.mkivela.com/pymnet/)
有人知道如何使用此图创建三层网络可视化吗?这些教程似乎一次只能添加一个节点,目前尚不清楚如何为此目的使用节点和边数据框。图层组在df_nodes中提供。
谢谢
答案 0 :(得分:1)
我也想知道,看看这篇文章: https://qiita.com/malimo1024/items/499a4ebddd14d29fd320 使用以下格式:mnet [from_node,to_node_2,layer_1,layer_2] = 1添加边(内部/内部)。 例如:
from pymnet import *
import matplotlib.pyplot as plt
%matplotlib inline
mnet = MultilayerNetwork(aspects=1)
mnet['sato','tanaka','work','work'] = 1
mnet['sato','suzuki','friendship','friendship'] = 1
mnet['sato','yamada','friendship','friendship'] = 1
mnet['sato','yamada','work','work'] = 1
mnet['sato','sato','work','friendship'] = 1
mnet['tanaka','tanaka','work','friendship'] = 1
mnet['suzuki','suzuki','work','friendship'] = 1
mnet['yamada','yamada','work','friendship'] = 1
fig=draw(mnet)