Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java
import java.util.Set;
class Graph{
  Set<Vertex> vertices;

  static class Vertex{
    int id;
    Set<Vertex> neighbours;
  }
}

Using Set containers is fine when order doesn't matter.
Of course, your implementation will also include constructors, edge methods, and graph traversal methods.
import java.util.List;
class Graph{
  List<Vertex> vertices;

  static class Vertex{
    int id;
    List<Vertex> neighbours;
  }
}

Of course, your implementation will also include constructors, edge methods, and graph traversal methods.
struct Vertex
{
	float x, y, z;
	Vertex* [] adjacentVertices;
}

New implementation...