Skip to content

Instantly share code, notes, and snippets.

from collections import Counter
import heapq
class Elements():
def __init__(self, key: int, val: int):
super().__init__()
self.key = key
self.val = val
def __repr__(self):
return f'Key: {self.key}, Val: {self.val}'
function doOnCurrentPageChanged(survey) {
document
.getElementById('surveyPrev')
.style
.display = !survey.isFirstPage
? "inline"
: "none";
document
.getElementById('surveyNext')
.style
# Assume all vertices are serial integers from 0 to V
V = 10
# Create Adjacency matrix. Fill all elements with zeros
# **Remember Adjacency matrix is just a 2D array
adj_matrix = [[0 for _ in range(V)] for _ in range(V)]
# Lets bring in edges. They are a list with first element pointing to second
edges = [[0,5], [1,2], [1,4], [1,5], [2,6], [3,7], [4,9]]
@karims
karims / adj_matrix.py
Last active May 25, 2019 12:46
Create adjacency matrix
# Set no. of vertices. Assume all vertices are serial integers from 0 to V
V = 10
# Create Adjacency matrix. Fill all elements with zeros
# **Remember Adjacency matrix is just a 2D array
adj_matrix = [[0 for _ in range(V)] for _ in range(V)]
# Lets bring in edges. They are a list with first element pointing to second
edges = [[0,5], [1,2], [1,4], [1,5], [2,6], [3,7], [4,9]]