Sharedscratchpaper.sagewsOpen in CoCalc
Author: Paul Zeitz
Views : 5
g = graphs.RandomGNM(15, 20) # 15 vertices and 20 edges show(g) g.incidence_matrix()
d3-based renderer not yet implemented
[1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 0 1 1 0 0 0 1 1 0 0 0 0 0] [1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0] [0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1] [0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0] [0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0] [0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0]
g1 = graphs.RandomGNM(100, 3000) # 15 vertices and 20 edges g2 = graphs.RandomGNM(100, 3000)
g1.is_isomorphic(g2)
False
g=graphs.CompleteBipartiteGraph(5,4) g.show()
show(g,vertex_labels=false)
d3-based renderer not yet implemented
#make a graph using a dictionary H=DiGraph({0:[1,2,3], 4:[0,2], 6:[1,2,3,4,5]}) plot(H)
v=['dog','cat','mouse'] dict={v[0]:[v[1],v[2]],v[1]:[v[0]],v[2]:[v[1]]} H=DiGraph(dict) plot(H)
mylist=[2,3,6] len(mylist)
3
len(p)
204226
#bulgarian solitaire def bs(myList): newItem=len(myList) output=[newItem] for x in myList: if x>1: output.append(x-1) return sorted(output)
bs([2,3,5])
[1, 2, 3, 4]
sorted([4,5,6,1,2])
[1, 2, 4, 5, 6]