#---------------------------------------------------------+ #name: netw2 ver: 1.0.0.0 | #--------------------------- -----------------------------+ #type: Package | #description: Teória grafov | #created: September 1997 modified: --- | #---------------------------------------------------------+ ##### # NeighbMatrix(G) - Matica susednosti ##### NeighbMatrix := proc(G) local ni, nj, i, j, n, T, Dlz, M, L; T := G(_EdgeIndex); #tabulka hran Dlz := G(_Eweight); #tabulka dlzok n := nops(vertices(G)); #pocet vrcholov M := array(1..n, 1..n); L := components(G); #komponenty grafu i := 1; j := 1; for ni in G(_Vertices) do for nj in G(_Vertices) do if type(T[ni, nj], set) then #existuje hrana M[i, j] := Dlz[T[ni, nj][1]] else if `networks/inOneComponent`(ni, nj, L) then M[i, j] := 0 #hrana neexistuje else M[i, j] := infinity #vrcholy su v roznych komponentoch fi fi; j := j + 1; od; j := 1; i := i + 1; od; eval(M) #vrat maticu susednosti end: ##### # DegreeMatrix(G) ##### DegreeMatrix := proc(G) local i, L; L := []; for i in vertices(G) do L := [op(L), vdegree(i, G)] od; eval(linalg[diag](op(L))) end: ##### # Frames(G): integer - pocet kostier grafu ##### Frames := proc(G) local M; M := evalm(DegreeMatrix(G) - NeighbMatrix(G)); M := linalg[delcols](M, 1..1); #odstran 1. stlpec M := linalg[delrows](M, 1..1); #odstran 1. riadok linalg[det](M) #vypocitaj determinant end: ##### # Test, ci je graf eulerovsky ##### Eulerian := proc(G) local x; for x in degreeseq(G) do if irem(x, 2) <> 0 then RETURN(false) fi; od; true end: ##### # Zisti, ci vrcholy su v tom istom komponente ##### `networks/inOneComponent` := proc(v1, v2, L) local i; for i from 1 to nops(L) do if member(v1, L[i]) and member(v2, L[i]) then RETURN(true) fi; od; false end: # Defining a help page. `help/text/netw2` := TEXT( `HELP FOR: Networks 2 ver 1.0, 1997`, ` `, `CALLING SEQUENCE:`, ` DegreeMatrix(G) - diagonalna matica stupnov vrcholov`, ` Eulerian(G): boolean - test, ci je graf eulerovsky`, ` Frames(G): integer - pocet kostier grafu`, ` NeighbMatrix(G) - matica susednosti`, ` `, ` `, ` networks/inOneComponent(v1, v2, components(G))`, ` `, `SEE ALSO: networks`):