大量のDiGraphデータを解析し、いくつかの論理テストを実行したいと思います。データは次のようになります。
Source,Target,DateTime
a,b,201212100401
a,d,201212100403
b,e,201212100511
b,c,201212100518
e,f,201212100610
c,a,201212100720
DataTimeスタンプはYYYYMMDDhhmmです...
私が探しているロジックがいくつかあります。たとえば、次のように検索します。AとCが話すが、前(AとB)(BとC)ではないインスタンス。したがって、プリントアウトは次のようになります。
Time 1| Time 2| Time 3
a,b,201212100401| b,c,201212100518| c,a,201212100720
私はこれらをnetworkxオブジェクトのようなものとして扱うことができると思います:
import networkx as nx
import sys
G = nx.DiGraph()
for line in (open(sys.argv[1])):
n1, n2, t1 = line.split(',')
G.add_edge(n1, n2, time=t1)
データがGに格納されたので、A、B、B、C、C、Aの関係をクエリする方法がわかりません。
誰か提案はありますか?