-
Notifications
You must be signed in to change notification settings - Fork 4
/
ContactNetworkEdge_NetworkX.py
executable file
·69 lines (56 loc) · 1.85 KB
/
ContactNetworkEdge_NetworkX.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/env python3
'''
Niema Moshiri 2016
"ContactNetworkEdge" module, implemented with NetworkX
'''
from ContactNetworkEdge import ContactNetworkEdge
from ContactNetworkNode import ContactNetworkNode
import FAVITES_GlobalContext as GC
class ContactNetworkEdge_NetworkX(ContactNetworkEdge):
'''
Implement the ``ContactNetworkEdge`` abstract class using NetworkX
Attributes
----------
u : ContactNetworkNode
The ``ContactNetworkNode'' object from which this edge is leaving
v : ContactNetworkNode
The ``ContactNetworkNode'' object to which this edge is going
attr : set of str
The attribute(s) of this ``ContactNetworkEdge'' object
'''
def init():
pass
def cite():
return GC.CITATION_NETWORKX
def __init__(self, u, v, attr):
'''
Construct a new ``ContactNetworkEdge_NetworkX`` object
Parameters
----------
graph : Graph
The NetworkX graph in which this node exists
node : Node
The NetworkX node encapsulated by this object
'''
assert isinstance(u, ContactNetworkNode), "u is not a ContactNetworkNode"
assert isinstance(v, ContactNetworkNode), "v is not a ContactNetworkNode"
assert isinstance(attr, set), "attr is not a set"
for item in attr:
assert isinstance(item, str), "attr contains a non-string item"
self.u = u
self.v = v
self.attr = attr
def __str__(self):
return '%r -> %r : %s' % (str(self.u), str(self.v), str(self.attr))
def get_attribute(self):
return self.attr
def get_from(self):
return self.u
def get_to(self):
return self.v
if __name__ == '__main__':
'''
This function is just used for testing purposes. It has no actual function
in the simulator tool.
'''
pass