本文整理汇总了Python中map.Map.isCovered方法的典型用法代码示例。如果您正苦于以下问题:Python Map.isCovered方法的具体用法?Python Map.isCovered怎么用?Python Map.isCovered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.isCovered方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TODO
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import isCovered [as 别名]
#-*- coding:utf-8 -*-
# AUTHOR: yaolili
# FILE: test.py
# ROLE: TODO (some explanation)
# CREATED: 2015-11-28 20:55:11
# MODIFIED: 2015-11-30 20:10:39
import os
import sys
from graph import GraphSet
from map import Map
if __name__ == '__main__':
if len(sys.argv) < 3:
print "sys.argv[1]: Graph file"
print "sys.argv[2]: subGraph file"
exit()
input = GraphSet(sys.argv[1])
#print input.curGraph(1)
print "VSet: ", input.curVSet(1)
print "ESet: ", input.curESet(1)
print "VESet: ", input.curVESet(1)
print "graph neighbor: ", input.neighbor(1, 1)
result = {}
curMap = Map(result)
print "isCovered: ", curMap.isCovered(input.curVESet(1))
neighbor = curMap.neighbor(1, input, 1)
print "map neighbor: ",neighbor
示例2: dfsMatch
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import isCovered [as 别名]
def dfsMatch(self, i, j, result):
#print "in dfsMatch() result: ", result
if not isinstance(result, dict):
print "Class Vf dfsMatch() arguments type error! result expected dict!"
curMap = Map(result)
'''
#test usage!
print "in dfsMatch() curMap.subMap() : ", curMap.subMap()
print "in dfsMatch() curMap.subMap() length: ", len(curMap.subMap())
print "in dfsMatch() self.__sub.curVSet(i) : ", self.__sub.curVSet(i)
print "in dfsMatch() self.__sub.curVSet(i) length: ", len(self.__sub.curVSet(i))
'''
if curMap.isCovered(self.__sub.curVSet(i)):
print "yes!"
return result
subMNeighbor = curMap.neighbor(i, self.__sub, 0, True)
gMNeighbor = curMap.neighbor(j, self.__origin, 1, True)
if not (subMNeighbor and gMNeighbor):
print "Class Vf dfsMatch(), subMNeighbor or gMNeighbor is empty!"
exit()
subNMNeighbor = curMap.neighbor(i, self.__sub, 0, False)
gNMNeighbor = curMap.neighbor(j, self.__origin, 1, False)
#print "in dfsMatch() subNMNeighbor: ", subNMNeighbor
#print "in dfsMatch() gNMNeighbor: ", gNMNeighbor
#notice, choose one vertex in subGraphNeighbor is ok
while(len(subNMNeighbor) > 1):
subNMNeighbor.pop()
'''
#test usage!
print "Class Vf dfsMatch() curMap.subMap(): ", curMap.subMap()
print "Class Vf dfsMatch() curMap.gMap(): ", curMap.gMap()
print "Class Vf dfsMatch() subMNeighbor: ", subMNeighbor
print "Class Vf dfsMatch() gMNeighbor: ", gMNeighbor
print "Class Vf dfsMatch() result: ", result
pairs = self.candidate(subMNeighbor, gMNeighbor)
print "Class Vf dfsMatch() pairs: ", pairs
'''
pairs = self.candidate(subNMNeighbor, gNMNeighbor)
if not pairs:
return result
for pair in pairs:
v1, v2 = pair.strip().split(":")
if(self.isMeetRules(int(v1), int(v2), i, j, result, curMap.subMap(), curMap.gMap(), subMNeighbor, gMNeighbor)):
result[int(v1)] = int(v2)
self.dfsMatch(i, j, result)
#notice, it's important to return result when len(result) == len(self.__sub.curVSet(i))
#otherwise it will continue to pop
if len(result) == len(self.__sub.curVSet(i)):
return result
result.pop(int(v1))
return result