Initial addition of Python scripts
This commit is contained in:
28
sliplink.py
Normal file
28
sliplink.py
Normal file
@ -0,0 +1,28 @@
|
||||
#from slipnode import Slipnode
|
||||
|
||||
class Sliplink(object):
|
||||
def __init__(self, source, destination, label=None, length=0.0):
|
||||
self.source = source
|
||||
self.destination = destination
|
||||
self.label = label
|
||||
self.fixedLength = length
|
||||
source.outgoingLinks += [self]
|
||||
destination.incomingLinks += [self]
|
||||
|
||||
def degreeOfAssociation(self):
|
||||
if self.fixedLength > 0 or not self.label:
|
||||
return 100.0 - self.fixedLength
|
||||
return self.label.degreeOfAssociation()
|
||||
|
||||
def intrinsicDegreeOfAssociation(self):
|
||||
if self.fixedLength > 1:
|
||||
return 100.0 - self.fixedLength
|
||||
if self.label:
|
||||
return 100.0 - self.label.intrinsicLinkLength
|
||||
return 0.0
|
||||
|
||||
def spread_activation(self):
|
||||
self.destination.buffer += self.intrinsicDegreeOfAssociation()
|
||||
|
||||
def points_at(self, other):
|
||||
return self.destination == other
|
||||
Reference in New Issue
Block a user