test_dfp_graph.py
Go to the documentation of this file.
1 from wirecell.dfp import graph, nodetype, dot
2 
3 # $ wire-cell -p WireCellGen -p WireCellApps -a NodeDumper
4 node_desc_json = '''
5 [
6  {
7  "category" : 1,
8  "concurrency" : 1,
9  "output_types" : [ "int", "float", "double", "int" ],
10  "type" : "A"
11  },
12  {
13  "category" : 3,
14  "concurrency" : 0,
15  "input_types" : ["int","float","double"],
16  "type" : "B"
17  }
18 ]
19 '''
20 
21 
22 def test_make():
23  'Make a wirecell.dfp.graph.Graph'
24  g = graph.Graph()
25  a = graph.key("A","a")
26  b = graph.key("B","b")
27  graph.connect(g, a,b, 0,0)
28  graph.connect(g, a,b, 1,1)
29  graph.connect(g, a,b, 2,2)
30  graph.connect(g, a,b, 3,0)
31 
32  desc = nodetype.loads(node_desc_json)
33  graph.validate(g, desc)
34 
35  gvgraph = dot.gvgraph_nodetypes(g, desc)
36  print gvgraph.string()
37 
38  # dot = g.dumps_dot()
39  # print dot
40  # open('foo.dot','w').write(dot)
41 
42  # g2 = Graph()
43  # g2.loads_dot(dot)
44  # print g2.dumps_dot()
45 
46 if '__main__' == __name__:
47  test_make()
48 
49