# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: SageMath 8.1
#     language: ''
#     name: sagemath
# ---

# +
# %matplotlib inline
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
 
def draw_plane_with_3points(points):
 
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
 
    p_array = np.array(points)
    p_array_T = p_array.T
    x = p_array_T[0]
    y = p_array_T[1]
    z = p_array_T[2]
 
    X, Y = np.meshgrid(x, y)
    _, Z = np.meshgrid(z, z)
    # Z = z.dot(np.ones([3,3])) # use z.T
 
    ax.plot_surface(X, Y, Z)
 
    ax.set_xlabel('X Label')
    ax.set_ylabel('Y Label')
    ax.set_zlabel('Z Label')
 
    ax.plot(x, y, z, '*')
 
    plt.show()
 
 
points = [
    [1, 1, 1],
    [2, 1, 1],
    [2, 2, 2],
]
 
draw_plane_with_3points(points)
# -

# ![fano.svg](attachment:fano.svg)

# %display latex
G = Graph([(1,2)]);G.show()
G.adjacency_matrix()

import networkx as nx
import matplotlib.pyplot as plt
G=nx.DiGraph(directed=True)
G.add_node(1,pos=(1,1))
G.add_node(2,pos=(2,2))
G.add_edge(1, 2, weight=0.5) 
G.add_edge(2, 1, weight=1)
pos=nx.get_node_attributes(G,'pos')
nx.draw_networkx(G,pos,arrows=True)
labels = nx.get_edge_attributes(G,'weight')
nx.draw_networkx_edge_labels(G,pos,edge_labels=labels)


import networkx as nx
A = nx.adjacency_matrix(G)
print(A.todense())

G = Graph([(1,2)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6),(4,7)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6),(4,7),(5,6)]);G.show()
G.adjacency_matrix()

G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6),(4,7),(5,6),(6,7)]);G.show()
G.adjacency_matrix()

from sage.graphs.graph_coloring import vertex_coloring
G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6),(4,7),(5,6),(6,7)])
S=vertex_coloring(G)
G.show(partition=S,figsize=3,graph_border=True)
G.adjacency_matrix()

g=Graph(7)
edges = [(1,2), (1,3), (1,4), 
    (2,3), (2,4), (2,5), (2, 6), 
    (3,4), (3,5), (3,6), (3,7), 
    (4,6), (4,7), (5,6), (6,7)]
g.add_edge(1,2),g.add_edge(1,3),g.add_edge(1,4),g.add_edge(2,3),
g.add_edge(2,4),g.add_edge(2,5),g.add_edge(2,6),g.add_edge(3,4),
g.add_edge(3,5),g.add_edge(3,6),g.add_edge(3,7),g.add_edge(4,6),
g.add_edge(4,7),g.add_edge(5,6),g.add_edge(6,7)
g.relabel({1:"kl",2:"i",3:"l",
           4:"j",5:"jl",6:"k",7:"il"})
g.show(figsize=4,graph_border=True)
g.adjacency_matrix()

from sage.graphs.graph_coloring import vertex_coloring
G = Graph([(1,2),(1,3),(1,4),(2,3),(2,4),
           (2,5),(2,6),(3,4),(3,5),(3,6),
           (3,7),(4,6),(4,7),(5,6),(6,7)])
S=vertex_coloring(G)
G.relabel({1:"kl",2:"i",3:"l",
           4:"j",5:"jl",6:"k",7:"il"})
G.show(figsize=4,graph_border=True)
G.adjacency_matrix()

32*64-2016

64*128-8128

# ![image.png](attachment:image.png)



StarcoderdataJupyterScriptsDedupFiltered