MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

dynamic_programming/floyd_warshall.py:5–12  ·  view source on GitHub ↗
(self, n=0)

Source from the content-addressed store, hash-verified

3
4class Graph:
5 def __init__(self, n=0): # a graph with Node 0,1,...,N-1
6 self.n = n
7 self.w = [
8 [math.inf for j in range(n)] for i in range(n)
9 ] # adjacency matrix for weight
10 self.dp = [
11 [math.inf for j in range(n)] for i in range(n)
12 ] # dp[i][j] stores minimum distance from i to j
13
14 def add_edge(self, u, v, w):
15 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected