Graph.Edge (libgraph v0.16.0)
This module defines the struct used to represent edges and associated metadata about them.
Used internally, v1
and v2
typically hold vertex ids, not the vertex itself, but all
public APIs which return Graph.Edge
structs, return them with the actual vertices.
Link to this section Summary
Functions
Defines a new edge and accepts optional values for weight and label. The defaults of a weight of 1 and no label will be used if the options do not specify otherwise.
Link to this section Types
Link to this type
edge_opt()
Link to this type
edge_opts()
@type edge_opts() :: [edge_opt()]
@type t() :: %Graph.Edge{ label: term(), v1: Graph.vertex(), v2: Graph.vertex(), weight: integer() | float() }
Link to this section Functions
Link to this function
new(v1, v2, opts \\ [])
@spec new(Graph.vertex(), Graph.vertex(), [edge_opt()]) :: t() | no_return()
Defines a new edge and accepts optional values for weight and label. The defaults of a weight of 1 and no label will be used if the options do not specify otherwise.
An error will be thrown if weight is not an integer or float.
example
Example
iex> Graph.new |> Graph.add_edge(Graph.Edge.new(:a, :b, weight: "1"))
** (ArgumentError) invalid value for :weight, must be an integer