-
Notifications
You must be signed in to change notification settings - Fork 7
/
graph_struct.pyx
42 lines (31 loc) · 1.25 KB
/
graph_struct.pyx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from cython.operator import dereference as deref
from libcpp.memory cimport shared_ptr
from libc.stdlib cimport free
cdef class py_GraphStruct:
cdef shared_ptr[GraphStruct] inner_GraphStruct
def __cinit__(self):
self.inner_GraphStruct = shared_ptr[GraphStruct](new GraphStruct())
def AddEdge(self,int idx, int x, int y):
deref(self.inner_GraphStruct).AddEdge(idx,x,y)
def AddNode(self,int subg_id, int n_idx):
deref(self.inner_GraphStruct).AddNode(subg_id,n_idx)
def Resize(self,unsigned _num_subgraph, unsigned _num_nodes):
deref(self.inner_GraphStruct).Resize(_num_subgraph,_num_nodes)
@property
def num_nodes(self):
return deref(self.inner_GraphStruct).num_nodes
@property
def num_edges(self):
return deref(self.inner_GraphStruct).num_edges
@property
def num_subgraph(self):
return deref(self.inner_GraphStruct).num_subgraph
@property
def edge_list(self):
return deref(self.inner_GraphStruct).edge_list
@property
def out_edges(self):
return deref(deref(self.inner_GraphStruct).out_edges).head
@property
def in_edges(self):
return deref(deref(self.inner_GraphStruct).in_edges).head