-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Not working
- Loading branch information
Showing
7 changed files
with
68 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright © 2024 Giovanni Squillero <[email protected]> | ||
// https://github.com/squillero/computational-intelligence | ||
// Free under certain conditions — see the license for details. | ||
|
||
package main | ||
|
||
import ( | ||
"demo-sp/viz" | ||
"math/rand" | ||
) | ||
|
||
func britishMuseum(graph *Graph, feed chan<- interface{}, tag int32) { | ||
cs := float32(graph.canvasSize) | ||
for { | ||
var p viz.TaggedPolyline | ||
p.Tag = tag | ||
p.Points = make([]viz.Point, 0) | ||
for np := 3 + rand.Intn(10); np > 0; np -= 1 { | ||
p.Points = append(p.Points, viz.Point{X: cs * rand.Float32(), Y: cs * rand.Float32()}) | ||
} | ||
feed <- p | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
2024-25/golang-demos/tsp/go.mod → 2024-25/golang-demos/shortest-path/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module demo | ||
module demo-sp | ||
|
||
go 1.21 | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright © 2024 Giovanni Squillero <[email protected]> | ||
// https://github.com/squillero/computational-intelligence | ||
// Free under certain conditions — see the license for details. | ||
|
||
package main | ||
|
||
import ( | ||
"demo-sp/viz" | ||
) | ||
|
||
const CanvasSize int = 1000 | ||
const WindowSize int = 800 | ||
|
||
func main() { | ||
// Create problem | ||
numVertexes := 50 | ||
edgeDensity := 0.01 | ||
|
||
// all passed by reference... | ||
feed := make(chan interface{}, numVertexes) | ||
graph := &Graph{canvasSize: CanvasSize} | ||
graph.initialize(numVertexes, edgeDensity) | ||
|
||
go func() { | ||
for _, c := range graph.nodes { | ||
feed <- viz.Circle{Color: viz.ColorBabyPink, Center: c, Radius: 5} | ||
} | ||
for n1 := 0; n1 < numVertexes; n1 += 1 { | ||
for n2 := n1 + 1; n2 < numVertexes; n2 += 1 { | ||
if graph.edges[n1][n2] > 0 { | ||
feed <- viz.Polyline{Color: viz.ColorBabyPink, | ||
Points: []viz.Point{graph.nodes[n1], graph.nodes[n2]}} | ||
} | ||
} | ||
} | ||
}() | ||
|
||
go britishMuseum(graph, feed, 0) | ||
go britishMuseum(graph, feed, 1) | ||
go britishMuseum(graph, feed, 2) | ||
go britishMuseum(graph, feed, 3) | ||
viz.Run(feed, "Zap!", CanvasSize, WindowSize) | ||
//britishMuseum(graph) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.