Show / Hide Table of Contents

Class RandomGraphFactory

Helpers related to graphs and randomness.

Inheritance
System.Object
RandomGraphFactory
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: QuikGraph.Algorithms
Assembly: QuikGraph.dll
Syntax
public static class RandomGraphFactory

Methods

| Improve this Doc View Source

Create<TVertex, TEdge>(IMutableUndirectedGraph<TVertex, TEdge>, VertexFactory<TVertex>, EdgeFactory<TVertex, TEdge>, Random, Int32, Int32, Boolean)

Fills the given graph with vertexCount vertices and edgeCount edges created randomly between vertices (undirected graph).

Declaration
public static void Create<TVertex, TEdge>(IMutableUndirectedGraph<TVertex, TEdge> graph, VertexFactory<TVertex> vertexFactory, EdgeFactory<TVertex, TEdge> edgeFactory, Random rng, int vertexCount, int edgeCount, bool selfEdges)
    where TEdge : IEdge<TVertex>
Parameters
Type Name Description
IMutableUndirectedGraph<TVertex, TEdge> graph

Graph to fill.

VertexFactory<TVertex> vertexFactory

Vertex factory method.

EdgeFactory<TVertex, TEdge> edgeFactory

Edge factory method.

System.Random rng

Random number generator.

System.Int32 vertexCount

Number of vertices to create.

System.Int32 edgeCount

Number of edges to create.

System.Boolean selfEdges

Indicates if self edge are allowed.

Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Exceptions
Type Condition
System.ArgumentNullException

graph is null.

System.ArgumentNullException

vertexFactory is null.

System.ArgumentNullException

edgeFactory is null.

System.ArgumentNullException

rng is null.

System.ArgumentOutOfRangeException

vertexCount is negative or equal 0.

System.ArgumentOutOfRangeException

edgeCount is negative.

| Improve this Doc View Source

Create<TVertex, TEdge>(IMutableVertexAndEdgeListGraph<TVertex, TEdge>, VertexFactory<TVertex>, EdgeFactory<TVertex, TEdge>, Random, Int32, Int32, Boolean)

Fills the given graph with vertexCount vertices and edgeCount edges created randomly between vertices (directed graph).

Declaration
public static void Create<TVertex, TEdge>(IMutableVertexAndEdgeListGraph<TVertex, TEdge> graph, VertexFactory<TVertex> vertexFactory, EdgeFactory<TVertex, TEdge> edgeFactory, Random rng, int vertexCount, int edgeCount, bool selfEdges)
    where TEdge : IEdge<TVertex>
Parameters
Type Name Description
IMutableVertexAndEdgeListGraph<TVertex, TEdge> graph

Graph to fill.

VertexFactory<TVertex> vertexFactory

Vertex factory method.

EdgeFactory<TVertex, TEdge> edgeFactory

Edge factory method.

System.Random rng

Random number generator.

System.Int32 vertexCount

Number of vertices to create.

System.Int32 edgeCount

Number of edges to create.

System.Boolean selfEdges

Indicates if self edge are allowed.

Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Exceptions
Type Condition
System.ArgumentNullException

graph is null.

System.ArgumentNullException

vertexFactory is null.

System.ArgumentNullException

edgeFactory is null.

System.ArgumentNullException

rng is null.

System.ArgumentOutOfRangeException

vertexCount is negative or equal 0.

System.ArgumentOutOfRangeException

edgeCount is negative.

| Improve this Doc View Source

GetEdge<TVertex, TEdge>(IEdgeSet<TVertex, TEdge>, Random)

Gets a random edge within the given graph.

Declaration
public static TEdge GetEdge<TVertex, TEdge>(IEdgeSet<TVertex, TEdge> graph, Random rng)
    where TEdge : IEdge<TVertex>
Parameters
Type Name Description
IEdgeSet<TVertex, TEdge> graph

The graph.

System.Random rng

Random number generator.

Returns
Type Description
TEdge

Chosen vertex.

Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Exceptions
Type Condition
System.ArgumentNullException

graph is null.

System.ArgumentNullException

rng is null.

| Improve this Doc View Source

GetEdge<TVertex, TEdge>(IEnumerable<TEdge>, Int32, Random)

Gets a random edge within the given set of edges.

Declaration
public static TEdge GetEdge<TVertex, TEdge>(IEnumerable<TEdge> edges, int count, Random rng)
    where TEdge : IEdge<TVertex>
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TEdge> edges

Set of edges.

System.Int32 count

Number of edges in the set.

System.Random rng

Random number generator.

Returns
Type Description
TEdge

Chosen vertex.

Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Exceptions
Type Condition
System.ArgumentNullException

edges is null.

System.ArgumentNullException

rng is null.

System.ArgumentOutOfRangeException

count is negative or equal 0.

System.InvalidOperationException

count is higher than edges count.

| Improve this Doc View Source

GetVertex<TVertex>(IVertexSet<TVertex>, Random)

Gets a random vertex within the given graph.

Declaration
public static TVertex GetVertex<TVertex>(IVertexSet<TVertex> graph, Random rng)
Parameters
Type Name Description
IVertexSet<TVertex> graph

The graph.

System.Random rng

Random number generator.

Returns
Type Description
TVertex

Chosen vertex.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

graph is null.

System.ArgumentNullException

rng is null.

| Improve this Doc View Source

GetVertex<TVertex>(IEnumerable<TVertex>, Int32, Random)

Gets a random vertex within the given set of vertices.

Declaration
public static TVertex GetVertex<TVertex>(IEnumerable<TVertex> vertices, int count, Random rng)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TVertex> vertices

Set of vertices.

System.Int32 count

Number of vertices in the set.

System.Random rng

Random number generator.

Returns
Type Description
TVertex

Chosen vertex.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

vertices is null.

System.ArgumentNullException

rng is null.

System.ArgumentOutOfRangeException

count is negative or equal 0.

System.InvalidOperationException

count is higher than vertices count.

  • Improve this Doc
  • View Source
In This Article
Back to top QuikGraph