Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go
type Graph[L any] []*Vertex[L]

type Vertex[L any] struct {
	Label      L
	Neighbours map[*Vertex[L]]bool
}

The map is used as a Set of Vertex pointers.
Graph is a list of all the Vertex pointers.
The type parameter L is for arbitrary node label data.
type Vertex struct{
	Id int
	Label string
	Neighbours map[*Vertex]bool
}

type Graph []*Vertex

The map is used as a Set of Vertex pointers.
Graph is a list of all the Vertex pointers.
struct Vertex
{
	float x, y, z;
	Vertex* [] adjacentVertices;
}

New implementation...