'''Takes a CSV of retrieved articles, and creates an igraph network from them (not even close to done)''' class CitationNetwork(igraph.Graph): def __init__(self, network_type): super().__init__(directed=True) self.temp_edges = [] self.temp_vertices = [] self.network_type = network_type def add_vertices(self, to_node, from_nodes): self.temp_vertices += [[from_node, to_node] for from_node in from_nodes] def make_network(self): # Get the unique set of nodes, and add them. nodes = set([v for v in self.temp_vertices if v['eid'] not in self.vs['name']]) nodes = sorted(nodes) self.add_vertices(nodes) self.add_edges(self.temp_edges) self.es['weight'] = 1 def collapse_weights(self): self.simplify(combine_edges={"weight": "sum"}) def add_citations(eid, citations): self.retrieved_eids.append(eid)