当前位置: 首页>>代码示例>>Python>>正文


Python Node.id方法代码示例

本文整理汇总了Python中Node.Node.id方法的典型用法代码示例。如果您正苦于以下问题:Python Node.id方法的具体用法?Python Node.id怎么用?Python Node.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: genPoints

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [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)'''
开发者ID:sagarjhaa,项目名称:Simulator_GUI,代码行数:27,代码来源:Simulator.py

示例2: select_nodes

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [as 别名]
	def select_nodes(self, midi_out):
		nodes = []
		if os.path.isfile('q.db'):
			for row in self.cursor.execute("""SELECT * FROM nodes"""):
				node = Node(midi_out=midi_out, do_rotation=False, do_scale=False)
				node.pos = (row[1], row[2])
				node.id = row[0]
				nodes.append(node)
		return nodes
开发者ID:,项目名称:,代码行数:11,代码来源:

示例3: genPoints

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [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)'''
开发者ID:sagarjhaa,项目名称:Simulator,代码行数:15,代码来源:Simulator.py

示例4: genPoints_GenForestFire

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [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)
开发者ID:sagarjhaa,项目名称:Network_Analysis,代码行数:51,代码来源:Simulator.py

示例5: genPoints

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [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)
开发者ID:sagarjhaa,项目名称:Network_Analysis,代码行数:42,代码来源:Simulator.py

示例6: genPoints_Snap

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import id [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)
开发者ID:sagarjhaa,项目名称:Simulator_GUI,代码行数:78,代码来源:Simulator.py


注:本文中的Node.Node.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。