我有将近1000个熊猫DataFrame,并将其转换为图形。现在,我可以访问这些图的边缘和节点。对于一个DataFrame,它看起来如下:
nx.edges(FG)
Out[59]: EdgeView([('Dy0O7', 'Dy1O6'), ('Dy0O7', 'Dy2O6'), ('Dy0O7', 'Dy3O7'), ('Dy0O7', 'Dy4O6'), ('Dy1O6', 'Dy3O7'), ('Dy1O6', 'Dy5O6'), ('Dy2O6', 'Dy4O6'), ('Dy3O7', 'Dy4O6'), ('Dy3O7', 'Dy5O6')])
nx.nodes(FG)
Out[61]: NodeView(('Dy0O7', 'Dy1O6', 'Dy2O6', 'Dy3O7', 'Dy4O6', 'Dy5O6'))
我还可以有一个邻接视图,该视图提供了具有相应权重的已连接节点的信息。
FG.adj
Out[64]: AdjacencyView({'Dy0O7': {'Dy1O6': {'weight': 3.0}, 'Dy2O6': {'weight': 1.0}, 'Dy3O7': {'weight': 2.0}, 'Dy4O6': {'weight': 1.0}}, 'Dy1O6': {'Dy0O7': {'weight': 3.0}, 'Dy3O7': {'weight': 1.0}, 'Dy5O6': {'weight': 1.0}}, 'Dy2O6': {'Dy0O7': {'weight': 1.0}, 'Dy4O6': {'weight': 1.0}}, 'Dy3O7': {'Dy0O7': {'weight': 2.0}, 'Dy1O6': {'weight': 1.0}, 'Dy4O6': {'weight': 3.0}, 'Dy5O6': {'weight': 1.0}}, 'Dy4O6': {'Dy0O7': {'weight': 1.0}, 'Dy2O6': {'weight': 1.0}, 'Dy3O7': {'weight': 3.0}}, 'Dy5O6': {'Dy1O6': {'weight': 1.0}, 'Dy3O7': {'weight': 1.0}}})
我想将这样的图形属性用作NN等机器学习算法的输入,我们该怎么做?