本文整理汇总了Python中Node.Node.x方法的典型用法代码示例。如果您正苦于以下问题:Python Node.x方法的具体用法?Python Node.x怎么用?Python Node.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.x方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: genPoints
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import x [as 别名]
def genPoints(self,Community_Coordinate):
"""
gen n Points
"""
#Test
#print Community_Coordinate
#raw_input()
#generator Points
for i in range(self.nPoints):
Random_Comm = random.choice(Community_Coordinate.keys())
XmaxNo = max(Community_Coordinate[Random_Comm][1])
XminNo = min(Community_Coordinate[Random_Comm][1])
YmaxNo = max(Community_Coordinate[Random_Comm][2])
YminNo = min(Community_Coordinate[Random_Comm][2])
node=Node()
node.id=i
node.x=random.randrange(XminNo+1,XmaxNo-20)
node.y=random.randrange(YminNo+1,YmaxNo-20)
self.pAll.append(node)
#print i, Random_Comm, node.x,node.y
'''self.genPointType(0.5,0.2,5,2)'''
示例2: genPoints
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import x [as 别名]
def genPoints(self):
"""
gen n Points
"""
#generator Points
for i in range(self.nPoints):
node=Node()
node.id=i
node.x=random.random()
node.y=random.random()
self.pAll.append(node)
'''self.genPointType(0.5,0.2,5,2)'''
示例3: genPoints_GenForestFire
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import x [as 别名]
def genPoints_GenForestFire(self,Community_Coordinate):
"""
gen n Points
"""
print "-" * 50
print "GenForestFire"
print "-" * 50
global NodeID
Graph = snap.GenForestFire(self.nPoints, 0.5,0.5)
temp = {}
for i in Graph.Nodes():
#print i.GetId()
temp[i.GetId()] = NodeID
NodeID = NodeID + 1
for i in Graph.Nodes():
XmaxNo = max(Community_Coordinate[1])
XminNo = min(Community_Coordinate[1])
YmaxNo = max(Community_Coordinate[2])
YminNo = min(Community_Coordinate[2])
node=Node()
node.id=temp[i.GetId()]#i.GetId()
r = lambda: random.randint(0,255)
rColor = '#%02X%02X%02X' % (r(),r(),r())
node.color = rColor
node.x=random.randrange(XminNo+1,XmaxNo-20)
node.y=random.randrange(YminNo+1,YmaxNo-20)
#self.pAll.append(node)
for EI in Graph.Edges():
if EI.GetSrcNId() == i.GetId():
#print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
if EI.GetSrcNId() <> EI.GetDstNId() :
node.follower.append(temp[EI.GetDstNId()])
#node.follower.append(EI.GetDstNId())
print node.id, node.follower
self.pAll.append(node)
示例4: genPoints
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import x [as 别名]
def genPoints(self,Community_Coordinate):
"""
gen n Points
"""
global NodeID
print "Random Network"
print "-" * 50
for i in range(self.nPoints):
XmaxNo = max(Community_Coordinate[1])
XminNo = min(Community_Coordinate[1])
YmaxNo = max(Community_Coordinate[2])
YminNo = min(Community_Coordinate[2])
node=Node()
node.id=NodeID
#print "NodeID ",node.id
NodeID = NodeID + 1
r = lambda: random.randint(0,255)
rColor = '#%02X%02X%02X' % (r(),r(),r())
node.color = "#CC0000" #rColor
roleList = ['T1','T2','T3']
node.role = random.choice(roleList)
if node.role == "T1":
node.probability = random.uniform(0,0.5)
if node.role == "T2":
node.probability = random.uniform(0,0.2)
if node.role == "T3":
node.probability = random.uniform(0,0.05)
node.x=random.randrange(XminNo+1,XmaxNo-20)
node.y=random.randrange(YminNo+1,YmaxNo-20)
self.pAll.append(node)
示例5: genPoints_Snap
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import x [as 别名]
def genPoints_Snap(self,Community_Coordinate):
"""
gen n Points
"""
#GenFull
#GenCircle
#GenGrid
#GenStar
#GenTree
#GenRndGnm
#GenPrefAttach
#GenGeoPrefAttach
#GenForestFire
#GenSmallWorld
#GenBaraHierar
#GenConfModel
#GenConfModel
#GenCopyModel
#GenDegSeq
#GenRewire
#GenRndDegK
#GenRndPowerLaw
#GenRMat
#GenRMatEpinions
Graph = snap.GenFull(snap.PNGraph, self.nPoints)
#Graph = snap.GenFull(snap.PUNGraph, 5)
#Graph = snap.GenFull(snap.PNEANet, 5)
#Graph = snap.GenCircle(snap.PNGraph, 5, 5)
#Graph = snap.GenCircle(snap.PUNGraph, 5, 5)
#Graph = snap.GenCircle(snap.PNEANet, 5, 5)
#Graph = snap.GenGrid(snap.PNGraph, 5, 5, False)
#Graph = snap.GenStar(snap.PNGraph, self.nPoints, True)
#Graph = snap.GenStar(snap.PUNGraph, self.nPoints, True)
#Graph = snap.GenStar(snap.PNEANet, self.nPoints, True)
#Graph = snap.GenTree(snap.PNGraph, self.nPoints, self.nPoints)
#Graph = snap.GenTree(snap.PUNGraph, self.nPoints, self.nPoints)
#Graph = snap.GenTree(snap.PNEANet, self.nPoints, self.nPoints)
#Graph = snap.GenRndGnm(snap.PNGraph, self.nPoints, self.nPoints)
#Graph = snap.GenRndGnm(snap.PUNGraph, self.nPoints, self.nPoints)
for i in Graph.Nodes():
XmaxNo = max(Community_Coordinate[1])
XminNo = min(Community_Coordinate[1])
YmaxNo = max(Community_Coordinate[2])
YminNo = min(Community_Coordinate[2])
node=Node()
node.id=i.GetId()
r = lambda: random.randint(0,255)
rColor = '#%02X%02X%02X' % (r(),r(),r())
node.color = rColor
node.x=random.randrange(XminNo+1,XmaxNo-20)
node.y=random.randrange(YminNo+1,YmaxNo-20)
#self.pAll.append(node)
for EI in Graph.Edges():
if EI.GetSrcNId() == i.GetId():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
if EI.GetSrcNId() <> EI.GetDstNId() :
node.follower.append(EI.GetDstNId())
self.pAll.append(node)