Exemples de base (2)
oGraph = new stzGraph("test")
oGraph.AddNodeXTT("alice", "Person", [:age = 30])
StzGraphQueryQ(oGraph) {
Match([:node = "n", :where = [:id, "=", "alice"]])
Set("n.age", [:to = 31])
Select("n")
? GraphQ().NodeProperty("alice", "age")
}31
exécuté le 2026-10-02 04:22 dans la bibliothèque au commit 0e72e2e2c ; tiré de 20_set_property.ring(s'ouvre dans un nouvel onglet)
p = new stzGraph("p")
p.AddNode("A") p.AddNode("B") p.AddNode("C")
p.AddEdge("A", "B") p.AddEdge("B", "C")
# a path is bipartite
? p.IsBipartite()
t = new stzGraph("t")
t.AddNode("X") t.AddNode("Y") t.AddNode("Z")
t.AddEdge("X", "Y") t.AddEdge("Y", "Z") t.AddEdge("Z", "X")
# a triangle (odd cycle) is not bipartite
? t.IsBipartite()1 0
exécuté le 2026-10-02 04:22 dans la bibliothèque au commit 0e72e2e2c ; tiré de 00_graph_narrated.ring(s'ouvre dans un nouvel onglet)
Portée (1)
m = new stzGraph("m")
m.AddNode("A") m.AddNode("B") m.AddNode("C") m.AddNode("D")
m.AddEdgeXTT("A", "B", "", [ :weight = 1 ])
m.AddEdgeXTT("B", "C", "", [ :weight = 2 ])
m.AddEdgeXTT("C", "D", "", [ :weight = 3 ])
m.AddEdgeXTT("D", "A", "", [ :weight = 4 ])
m.AddEdgeXTT("A", "C", "", [ :weight = 5 ])
# the MST weight is 1+2+3 = 6
? m.MSTWeight()
d = new stzGraph("d")
d.AddNode("A") d.AddNode("B") d.AddNode("X")
d.AddEdge("A", "B")
# a graph with no spanning tree returns -1
? d.MSTWeight()6 -1
exécuté le 2026-10-02 04:22 dans la bibliothèque au commit 0e72e2e2c ; tiré de 00_graph_narrated.ring(s'ouvre dans un nouvel onglet)
Les extensions de cette méthode
Chaque extension, et si elle existe pour cette méthode ; une extension qui existe se compose avec les autres (FindSTCS).
Chaque exemple est un fichier de test de la bibliothèque, exécuté dans la bibliothèque pour cette page ; seuls ceux dont la sortie a tenu toutes les promesses écrites par leur fichier sont montrés. Les explications, les titres et le code sont ceux de la bibliothèque, en anglais.
Voir aussi
- La classe stzGraph
- La référence du domaine : Diagrammes et graphes
- Les autres méthodes de ces exemples : stzGraph.AddEdge · stzGraph.IsBipartite · stzGraph.MSTWeight

