File size: 305 Bytes
602b5b1
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import networkx as nx

class GraphBuilder:
    def build(self, intents):
        graph = nx.DiGraph()
        for i, intent in enumerate(intents):
            graph.add_node(intent, type='intent')
            if i > 0:
                graph.add_edge(intents[i-1], intent, weight=1.0)
        return graph