MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / create_edge

Function create_edge

graphs/frequent_pattern_graph_miner.py:130–151  ·  view source on GitHub ↗

create edge between the nodes

(nodes, graph, cluster, c1)

Source from the content-addressed store, hash-verified

128
129
130def create_edge(nodes, graph, cluster, c1):
131 """
132 create edge between the nodes
133 """
134 for i in cluster[c1]:
135 count = 0
136 c2 = c1 + 1
137 while c2 < max(cluster.keys()):
138 for j in cluster[c2]:
139 """
140 creates edge only if the condition satisfies
141 """
142 if int(i, 2) & int(j, 2) == int(i, 2):
143 if tuple(nodes[i]) in graph:
144 graph[tuple(nodes[i])].append(nodes[j])
145 else:
146 graph[tuple(nodes[i])] = [nodes[j]]
147 count += 1
148 if count == 0:
149 c2 = c2 + 1
150 else:
151 break
152
153
154def construct_graph(cluster, nodes):

Callers 1

construct_graphFunction · 0.85

Calls 2

keysMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected