def getFeatureVecBasic(G, nid): node = G.GetNI(nid) feat1 = node.GetDeg() # Now get egonet ego = snap.TNGraph() ego.AddNode(node.GetId()) # Add all of the neighbors and edge to node Nbrs = snap.TIntV() snap.GetNodesAtHop(G, nid, 1, Nbrs, True) Nbrs.Add(nid) feat2, feat3 = snap.GetEdgesInOut(G, Nbrs) # Return the vec return np.array([feat1, feat2, feat3])
def graph_snap(page_title, wikilink_link, node_idx_dict): graph_snap = snap.TNGraph().New() edge_list = graph_edge_list(page_title, wikilink_link) for node1 in edge_list: node1_idx = node_idx_dict[node1] if (not graph_snap.IsNode(node1_idx)): graph_snap.AddNode(node1_idx) node2_list = edge_list[node1] for node2 in node2_list: if node2 in node_idx_dict: node2_idx = node_idx_dict[node2] if (not graph_snap.IsNode(node2_idx)): graph_snap.AddNode(node2_idx) if (not graph_snap.IsEdge(node1_idx, node2_idx)): graph_snap.AddEdge(node1_idx, node2_idx) return graph_snap
import snap g = snap.TNGraph() g.AddNode() NI = g.BegNI() print NI dir(NI)