コード例 #1
0
def function():
    g = graphss.Graph({})
    for i in range(0, len(str) - 1):
        g.add_edge(str[i], str[i + 1])
    b = bfsPro.bfs()
    b.bfs(g.logs())
    graph = g.logs()
    print graph
    list = []
    state = 0

    for Node in graph.keys():
        state = 0

        for inner_node in graph[Node].keys():

            if (state == 0):

                if graph[Node][inner_node] > 1:
                    list.append(Node)
                    list.append(inner_node)
                    graph[Node][inner_node] = graph[Node][inner_node] - 2
                    state = 1

            elif (state == 1):
                if graph[Node][inner_node] > 1:
                    list.append(inner_node)
                    graph[Node][inner_node] = graph[Node][inner_node] - 2

    print list
コード例 #2
0
 def graphs(self):
     g = graphss.Graph()
     g.add_edge('a', 'b')
     g.add_edge('a', 'c')
     g.add_edge('b', 'd')
     g.add_edge('b', 'e')
     g.add_edge('c', 'f')
     g.add_edge('c', 'g')
     g.add_edge('g', 'a')
     self.graph = g.get_the_graph()
     print self.graph
     self.bfslist()
コード例 #3
0
class programx:
    g = graphss.Graph({})
    for i in range(0,len(str)-1):
        g.add_edge(str[i],str[i+1])

    find_the_sequences(g.logs())

    print(g.logs())



    graph =g.logs()
    b=bfsPro.bfs()
    b.bfs(graph)
    print("------------")


    print("_________>>>>")


    bfslist = b.get_bfs_list()

    print("------")
    for node in bfslist:

        if node in graph.keys():
         for graph_node in graph[node].keys():
             if graph[node][graph_node]>1:
                # graph[node][graph_node]=graph[node][graph_node]-2
                 print node,  graph_node



    def find_the_sequences(self,graph={}):
        graphs=graph
        list=[]
        state=0
        for Node in graphs.keys():
            state=0
            for inner_node in graph[Node].keys:
                if state==0:
                    if graph[Node][inner_node]>1:
                        list.append(Node)
                        list.append(inner_node)
                        graph[Node][inner_node]=graph[Node][inner_node]-2
                        state=1
                elif state==1:
                    if graph[Node][inner_node] > 1:
                        list.append(inner_node)
                        graph[Node][inner_node] = graph[Node][inner_node] - 2

        return list
コード例 #4
0
ファイル: fin.py プロジェクト: thoufeeqhidayath/pythonExample
    def function(self):
        g = graphss.Graph({})
        for i in range(0, len(str) - 1):
            g.add_edge(str[i], str[i + 1])
        self.graph = g.logs()
        b = bfsPro.bfs()
        b.bfs(g.logs())
        self.bfs_list = b.get_bfs_list()
        for node in self.bfs_list:
            for m in self.graph[node].keys():
                if self.graph[node][m] > 1:
                    self.sequences.append("||")
                    self.sequences.append(node)
                    self.depth_search(node)

        print self.sequences
コード例 #5
0
import graphss


def sample1():
    i = 0


g = graphss.Graph({})
g.add_vertex("a")
g.add_vertex("b")
g.add_vertex("c")
g.add_vertex("d")
g.add_vertex("f")
g.add_edge('a', 'e')
g.add_edge('a', 'c')
g.add_edge('a', 'd')
g.add_edge('f', 'a')
g.add_edge('v', 'w')
g.add_edge('v', 'w')
g.log()
コード例 #6
0
 def add_into_graph(self):
     g = graphss.Graph({})
     for i in range(0, len(str) - 1):
         g.add_edge(str[i], str[i + 1])
     self.graph = g.logs()
     self.find_bfs()
コード例 #7
0
 def add_to_graph(self):
     graph = graphss.Graph({})
     for vertex in range(0, len(str) - 1):
         graph.add_edge(str[vertex], str[vertex + 1])
     self.graph = graph.get_the_graph()
     self.get_bfs_list()