All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.alexandrepiveteau.graphs.builder.GraphBuilderScope.kt Maven / Gradle / Ivy

package io.github.alexandrepiveteau.graphs.builder

import io.github.alexandrepiveteau.graphs.Graph
import io.github.alexandrepiveteau.graphs.Vertex

/** A [GraphBuilderScope] is scope which can be used to build a [Graph]. */
public fun interface GraphBuilderScope {

  /** Adds a new vertex to the graph, and returns it. */
  public fun addVertex(): Vertex

  /** Returns a new [Vertices] instance. */
  public fun addVertices(): Vertices = Vertices { addVertex() }
}

/** A [Vertices] is a helper class which allows to create multiple [Vertex]s at once. */
public fun interface Vertices {
  public operator fun invoke(): Vertex
  public operator fun component1(): Vertex = invoke()
  public operator fun component2(): Vertex = invoke()
  public operator fun component3(): Vertex = invoke()
  public operator fun component4(): Vertex = invoke()
  public operator fun component5(): Vertex = invoke()
  public operator fun component6(): Vertex = invoke()
  public operator fun component7(): Vertex = invoke()
  public operator fun component8(): Vertex = invoke()
  public operator fun component9(): Vertex = invoke()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy