<<VilCretas`

GrafoString["Bienvenido"]

nodos={e,g,a,h,b,f,d,c};
grafo=Grafo[{{a,b},{a,c},{a,d},{a,e},{b,g},{b,h},{c,e},{c,f},{c,g},{d,e},{d,f},{d,g},{d,h},{e,f},{e,g},{e,h},{f,h}},pesos->-{8,4,1,3,10,10,1,4,4,7,6,10,7,1,7,8,3},mostrarpesos->True];
Kruskal[grafo];

Prim[grafo,orden->nodos]

gr1=Grafo[{{a,f},{a,g},{a,h},{a,j},{b,c},{b,d},{b,e},{b,h},{b,i},{c,e},{d,f},{e,f},{f,g},{f,j},{i,j}},pesos->-{15,3,16,49,32,41,43,3,1,49,25,28,9,11,48},mostrarpesos->True];

AlDijkstra[gr1, a,g, all->True]

gr1

aristas={{a,b},{a,c},{a,e},{b,c},{b,d},{b,e},{c,d},{c,e},{d,d},{c,c},{d,e}};
pes={7,5,2,8,3,14,6,2,6,4,2};
gra1 = Grafo[aristas, pesos->pes, mostrarpesos->True]

Valencias[gra1]

?MPGrafo

MPGrafo[gra1, {a,b,c,d,e}, table->True]

ListaVertices[gra1]

CantAristas[gra1]

Matriz de incidencia

?MIGrafo

MIGrafo[gra1,{a,b,c,d,e}, table->True]

arist ={{1,2},{1,4},{1,5},{1,7},{1,8},{1,10},{2,3},{2,4},{2,5},{2,6},{2,7},{2,8},{2,9},{3,5},{3,7},{3,10},{4,5},{4,8},{4,10},{5,6},{5,8},{5,10},{6,8},{6,10},{7,9},{8,9},{8,10},{9,10}};
gra2=Grafo[arist, dirigido->True, vertices->Range[10]]

Valencias[gra2]

Hamilton y Euler
(Subscript[K, 1000, 1000]) ->Knm

(Subscript[K, 1000]) -> Kn
Luego ver si es circuito o ruta, y por ultimo ver si es Hamilton o Euler

KnCircuitoHamiltonQ
KnCircuitoEulerQ
KnRutaHamiltonQ
KnRutaEulerQ

KnmCircuitoEulerQ
KnmCircuitoHamiltonQ
KnmRutaEulerQ
KnmRutaHamiltonQ

KnmCircuitoHamiltonQ[500,500]

KnCircuitoEulerQ[21534]

KnCircuitoHamiltonQ[14147]&&KnRutaHamiltonQ[14147]

GrafoBipartitoCompleto[10,5]

ArbolQ[GrafoBipartitoCompleto[10,5]]

GrafoCompleto[10]

grafo=Grafo[{{1,3},{1,6},{1,7},{1,12},{2,7},{2,9},{2,11},{2,12},{3,9},{3,10},{4,7},{4,10},{5,9},{6,7},{6,10},{7,10},{8,9},{9,10},{9,11},{9,12}},pesos->-1 {14,6,14,12,6,13,2,2,4,17,16,19,8,18,20,11,11,18,1,6},mostrarpesos->True]

AlDijkstra[grafo, 6,8]

AlDijkstra[grafo, 6,8, all->True]

Inicio a Fin: 6->10->4->7->1->3->9->8
Fin a Inicio: 8->9->3->1->7->4->10->6
Recordar en la longitud usar el valor absoluto: |-n| -> n

Error común

grafo2=Grafo[{{1,3},{1,6},{1,7},{1,12},{2,7},{2,9},{2,11},{2,12},{3,9},{3,10},{4,7},{4,10},{5,9},{6,7},{6,10},{7,10},{8,9},{9,10},{9,11},{9,12}},pesos->{14,6,14,12,6,13,2,2,4,17,16,19,8,18,20,11,11,18,1,6},mostrarpesos->True]

AlDijkstra[grafo2, 6,8]

nodos={d,a,f,g,e,b,c,h};

grafo=Grafo[{{a,b},{a,d},{a,e},{a,f},{b,d},{b,e},{b,g},{b,h},{c,d},{c,f},{c,g},{c,h},{d,e},{e,f},{f,g},{f,h},{g,h}},pesos->{6,9,2,4,2,4,1,9,1,8,2,4,4,3,9,3,2},mostrarpesos->True];

?BuscarPrimeroAncho
?BuscarPrimeroLargo

BuscarPrimeroLargo[grafo, animacion->True, orden->nodos]

BuscarPrimeroAncho[grafo, animacion->True, orden->nodos]

nodos

Sort/@{{d,a},{d,e},{d,b},{d,c},{a,f},{g,b},{b,h}}

matr=(({{1, 0, 0, 0, 0}, {1, 1, 1, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}));
MGrafo[GrafoMI[matr,{a,b,c,d,e}],{a,b,c,d,e}]

?MPGrafo

?MGrafo