0

So I am trying to build a python application that manages a directed temporal graph (so edges happen at a time T). I am using DyNetx with the function to read the graph from a Dataset where every row is a 3-tuple that has: startNode, endNode, timestamp. Problem is, I wanted to store every single node as Node type object which is a class i created with attributes id and status since the focus of the program is to study influence maximization. I get the id from the file and I initialize every node with status 0. But when at some point in the code I change the status of the code, if that node appears later in another edge of the graph its status is resetted to 0, i think its because with custom node types there is no way to check if a node already exists..so my question is, is there a way to change the function that reads the temporal graph from the file so that if the same id occurrs twice the node associated is the same and there are no other objects created? or a way to give a status attribute to a node when rapresenting it as an int? code below

import dynetx
```
class Node:
    def __init__(self, id):
        self.id = int(id)
        self.status = 0
```

g = dynetx.read_snapshots('college.txt', nodetype=Node, timestamptype=int)
for e in g.stream_interactions():
    print(e[0].id)
    print(e[0].status)
```
21 Gix
  • 1

0 Answers0