Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
type Vertex struct{
Id int
Label string
Neighbours map[*Vertex]bool
}
type Graph []*Vertex
struct Vertex
{
float x, y, z;
Vertex* [] adjacentVertices;
}
Vertex = Struct.new(:x, :y, :z)
Graph = Struct.new(:vertex, :neighbours)
v = Vertex.new(1, 2, 3)
neighbours = [ Vertex.new(2, 3, 4), Vertex.new(4, 5, 6) ]
graph = Graph.new(v, neighbours)
datatype Node = Int
datatype Adjacencies = [ Node ]
datatype Graph = [ Adjacencies ]
inline class VertexId(val id: Int)
data class Vertex(val id: VertexId, val neighbours: Set<VertexId>)
data class Graph(val vertices: Set<Vertex>)
type Graph[L any] []*Vertex[L]
type Vertex[L any] struct {
Label L
Neighbours map[*Vertex[L]]bool
}