def process(self, params, input_stream): logging.debug(params) # Convert to graph-tool objects gs = GraphToolAdapter.to_graph_tool(input_stream) ts, tposs = self.process_graphs(params, gs) return GraphToolAdapter.from_graph_tool(ts, tposs, False)
def testMultipleNetworks(self): nets = [ create_mock_graph_tool('net1')[0], create_mock_graph_tool('net2')[0] ] streams = GraphToolAdapter.from_graph_tool(nets) res_nets = GraphToolAdapter.to_graph_tool(streams) compare_graph_tool(nets[0], res_nets[0]) compare_graph_tool(nets[1], res_nets[1])
def testUnusualAttributeType(self): net, edgeList = create_mock_graph_tool(num_nodes=100, num_edges=50, data={'keyDict': { 1: 2 }}) stream = GraphToolAdapter.from_graph_tool([net]) net_res_list = GraphToolAdapter.to_graph_tool(stream) compare_graph_tool(net, net_res_list[0]) # autoconvert to string for unrecognized value types self.assertEqual(str(net.gp['keyDict']), net_res_list[0].gp['keyDict'])
def test_to_graph_tool(self): net, edgeList = create_mock_graph_tool(num_nodes=100, num_edges=50, data={ 'keyStr': 'value', 'keyInt': 1, 'keyFloat': 1.2, 'keyBool': True }) stream = GraphToolAdapter.from_graph_tool([net]) net_res_list = GraphToolAdapter.to_graph_tool(stream) compare_graph_tool(net, net_res_list[0]) self.assertEqual(net.gp.keys(), net_res_list[0].gp.keys()) for k in net.gp.keys(): self.assertEqual(net.gp[k], net_res_list[0].gp[k])
def testLargeNetwork(self): net, edgeList = create_mock_graph_tool(num_nodes=10000, num_edges=5000) stream = GraphToolAdapter.from_graph_tool([net]) net_res_list = GraphToolAdapter.to_graph_tool(stream) compare_graph_tool(net, net_res_list[0])
def process(self, params, input_stream): logging.debug(params) ol = params.pop("only-layout") gs = GraphToolAdapter.to_graph_tool(input_stream) gs, poss = self.process_graphs(params, gs) return GraphToolAdapter.from_graph_tool(gs, poss, ol)