Example #1
0

numEdges=graph.getNumEdges()

print "\nVertices: " + str(graph.getNumVertices())
print "Edges: " + str(graph.getNumEdges())

#-----------------------------------
# Here is where we choose a random start/goal locations. You probably don't need to touch any of this. 
if(file_provided==False):
    goal=[]
    start=[]
    #---- Get random start ------------------
    while start==[]:
        id=int((i*random.random())%i)
        vrtx=graph.getVertex(id)
        if(len(graph.neighbours(id))>1):
            x=vrtx[0]
            y=vrtx[1]
            if(x!=0 and x!=colLength and y!=0 and y!=rowLength):
                start=[x,y]  

    #---- Get random goal -------------------
    while goal==[]:
        id=int((i*random.random())%i)
        vrtx=graph.getVertex(id)
        if(len(graph.neighbours(id))>1):
            x=vrtx[0]
            y=vrtx[1]
            if(start!=[x,y] and x!=0 and x!=colLength and y!=0 and y!=rowLength):
                goal=[x,y] 
Example #2
0

numEdges=graph.getNumEdges()

print "\nVertices: " + str(graph.getNumVertices())
print "Edges: " + str(graph.getNumEdges())

#-----------------------------------
# Here is where we choose a random start/goal locations. You probably don't need to touch any of this. 
if(file_provided==False):
    goal=[]
    start=[]
    #---- Get random start ------------------
    while start==[]:
        id=int((i*random.random())%i)
        vrtx=graph.getVertex(id)
        if(len(graph.neighbours(id))>1):
            x=vrtx[0]
            y=vrtx[1]
            if(x!=0 and x!=colLength and y!=0 and y!=rowLength):
                start=[x,y]  

    #---- Get random goal -------------------
    while goal==[]:
        id=int((i*random.random())%i)
        vrtx=graph.getVertex(id)
        if(len(graph.neighbours(id))>1):
            x=vrtx[0]
            y=vrtx[1]
            if(start!=[x,y] and x!=0 and x!=colLength and y!=0 and y!=rowLength):
                goal=[x,y]