Skip to content

Instantly share code, notes, and snippets.

View RobertTalbert's full-sized avatar

Robert Talbert RobertTalbert

View GitHub Profile
def flatten_list(lst):
flattened = []
for item in lst:
if isinstance(item, list):
flattened.extend(flatten_list(item))
else:
flattened.append(item)
return flattened
[3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293,
313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683,
733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123,
1153, 1163, 1193, 1223, 1283, 1303, 1373, 1423, 1433, 1453, 1483, 1493, 1523,
1553, 1583, 1613, 1663, 1733, 1783, 1823, 1823, 1873, 1913, 1933, 1973, 1993,
2003, 2053, 2083, 2113, 2143, 2153, 2203, 2213, 2273, 2293, 2333, 2383, 2393,
2423, 2473, 2503, 2543, 2593, 2633, 2663, 2683, 2693, 2713, 2753, 2803, 2833,
2843, 2903, 2953, 2963]
@RobertTalbert
RobertTalbert / gpTemplate.md
Created July 8, 2015 17:40
Markdown template file for Guided Practice assignments

Title

Overview

Overview

Learning objectives

Basic objectives: Each student is responsible for gaining proficiency with each of these tasks prior to engaging in class discussions, through the use of the learning resources (below) and through the working of exercises (also below).

# Load libraries
import networkx as nx
import matplotlib.pyplot as plt
# Generate the graph
## The second parameter is a probability that two distinct vertices are adjacent
## Raise the probability for more connections
g = nx.gnp_random_graph(8, 0.5)
@RobertTalbert
RobertTalbert / warshall.py
Created February 19, 2016 18:50
SageMath implementation of Warshall's algorithm
def warshall(M):
n = M.nrows()
W = M
for k in range(n):
for i in range(n):
for j in range(n):
W[i,j] = W[i,j] or (W[i,k] and W[k,j])
return W
# List of trails in North Ottawa Dunes park given as tuples.
# Vertex 100 = Trailhead in Coast Guard Park
# Vertex 200 = Trailhead at North Beach Park
# Vertex 300 = Trail endpoint at Hoffmaster State Park
[(100,1,.30), (1,24,.16), (1,2,.20), (2,19,.11), (19,25,.07),
(19,20,.16), (20,200, .16), (2,3,.49), (3,23,.11), (3,4,.34),
(4,23,.34), (4,18,.07), (4,21,.22), (5,21,.09), (5,6,.16),
(5,15,.23), (6,7,.34), (6,16,.07), (7,12,.12), (7,8,.15), (8,9,.21),
(8,13,.25), (9,10,.06), (10,11,.21), (10,12,.51), (11,300,.12),

List of graph isomorphism invariants

This is a running list of graph isomorphism invariants, that is, properties of graphs such that...

If $G$ and $H$ are isomorphic and $G$ has the property, then $H$ also has the property.

A logically equivalent way to say this is:

If $G$ has the property but $H$ does not, then $G$ and $H$ are not isomorphic.

# Generate a random tree
random_tree = nx.random_tree(n)
# Draw the tree
nx.draw(random_tree, with_labels=True, node_color="lightblue", font_weight="bold")
plt.show()
# Python code for MTH 325 F24 Homework 5
## 1. Iterating through a list
vertex_list = [(2,3), (2,4), (4,5), (1,3)]
for vertex in vertex_list:
print(vertex[1])
## 2. A dictionary

Weekly Review

Get clear

  • Weekly wipedown
  • Collect loose items and get into physical inbox
  • Inbox Zero
    • Physical inbox
    • Personal Gmail
    • Work email - Outlook