InductiveGraph.Internal (InductiveGraph v0.1.0) View Source

Functions to manage internal representation of inductive graph.

Link to this section Summary

Construction Functions

Adds edge_values with neighbor to adjacents.

Adds edge_values with neighbor to either predecessor or successor adjacents position in context.

Creates an empty graph.

Inserts tagged_edge into graph.

Inserts tagged_edges into graph.

Inserts tagged_vertex into graph.

Inserts tagged_vertices into graph.

Creates a graph from tagged_vertices and tagged_edges.

Merges context into graph.

Creates a new context based on vertex_value.

Destruction Functions

Decomposes graph into the context containing vertex and the remaining graph.

Removes edges with neighbor from either predecessor or successor adjacents position in contexts of vertices.

Removes edges with neighbor from either predecessor or successor adjacents position in context.

Update Functions

Applies function to adjacents.

Applies function to every edge value in graph.

Applies function to every context in graph.

Applies function to every vertex value in graph.

Applies vertex_function to every vertex value and edge_function to every edge value in graph.

Updates context by function based on update_type.

Conversion Functions

Converts adjacents to [{edge_value, neighbor}].

Converts context to {[{edge_value, neighbor}], vertex, vertex_value, [{edge_value, neighbor}]}.

Converts [{edge_value, neighbor}] to adjacents.

Converts {[{edge_value, neighbor}], vertex, vertex_value, [{edge_value, neighbor}]} to context.

Inspection Functions

Counts number of vertices in graph.

Determines if graph is empty.

Determines if edge is in graph.

Determines if vertex is in graph.

Lists all tagged edges in graph.

Lists all vertices in graph.

Pretty prints inductive representation of graph.

Gets range of vertex in graph.

Link to this section Types

Specs

adjacents() :: %{required(neighbor()) => [edge_value()]}

Specs

context() :: {predecessors(), vertex_value(), successors()}

Specs

edge() :: InductiveGraph.edge()

Specs

edge_value() :: InductiveGraph.edge_value()

Specs

neighbor() :: InductiveGraph.neighbor()

Specs

predecessors() :: adjacents()

Specs

successors() :: adjacents()

Specs

t() :: %{required(vertex()) => context()}

Specs

tagged_edge() :: InductiveGraph.tagged_edge()

Specs

tagged_vertex() :: InductiveGraph.tagged_vertex()

Specs

value() :: InductiveGraph.value()

Specs

vertex() :: InductiveGraph.vertex()

Specs

vertex_value() :: InductiveGraph.vertex_value()

Link to this section Construction Functions

Link to this function

add_edges_to_adjacents(adjacents, neighbor, edge_values)

View Source

Specs

add_edges_to_adjacents(adjacents(), neighbor(), [edge_value()]) :: adjacents()

Adds edge_values with neighbor to adjacents.

Link to this function

add_edges_to_context(context, neighbor, edge_values, position)

View Source

Specs

add_edges_to_context(
  context(),
  neighbor(),
  [edge_value()],
  :predecessors | :successors
) :: context()

Adds edge_values with neighbor to either predecessor or successor adjacents position in context.

Specs

empty_graph() :: t()

Creates an empty graph.

Link to this function

insert_tagged_edge(graph, tagged_edge)

View Source

Specs

insert_tagged_edge(t(), tagged_edge()) :: {:ok, t()} | :error

Inserts tagged_edge into graph.

Link to this function

insert_tagged_edges(graph, tagged_edges)

View Source

Specs

insert_tagged_edges(t(), [tagged_edge()]) :: {:ok, t()} | :error

Inserts tagged_edges into graph.

Link to this function

insert_tagged_vertex(graph, tagged_vertex)

View Source

Specs

insert_tagged_vertex(t(), tagged_vertex()) :: {:ok, t()} | :error

Inserts tagged_vertex into graph.

Link to this function

insert_tagged_vertices(graph, tagged_vertices)

View Source

Specs

insert_tagged_vertices(t(), [tagged_vertex()]) :: {:ok, t()} | :error

Inserts tagged_vertices into graph.

Link to this function

make_graph(tagged_vertices, tagged_edges)

View Source

Specs

make_graph([tagged_vertex()], [tagged_edge()]) :: {:ok, t()} | :error

Creates a graph from tagged_vertices and tagged_edges.

Specs

merge(t(), InductiveGraph.context()) :: {:ok, t()} | :error

Merges context into graph.

Link to this function

new_context(vertex_value)

View Source

Specs

new_context(vertex_value()) :: context()

Creates a new context based on vertex_value.

Link to this section Destruction Functions

Link to this function

decompose(graph, vertex)

View Source

Specs

decompose(t(), vertex()) :: {:ok, InductiveGraph.context(), t()} | :error

Decomposes graph into the context containing vertex and the remaining graph.

Link to this function

prune_adjacents(graph, vertices, neighbor, position)

View Source

Specs

prune_adjacents(t(), [vertex()], neighbor(), :predecessors | :successors) ::
  {:ok, t()} | :error

Removes edges with neighbor from either predecessor or successor adjacents position in contexts of vertices.

Link to this function

remove_edges_from_context(context, neighbor, position)

View Source

Specs

remove_edges_from_context(context(), neighbor(), :predecessors | :successors) ::
  context()

Removes edges with neighbor from either predecessor or successor adjacents position in context.

Link to this section Update Functions

Link to this function

map_adjacents(adjacents, function)

View Source

Specs

map_adjacents(adjacents(), function()) :: adjacents()

Applies function to adjacents.

Link to this function

map_edges(graph, function)

View Source

Specs

map_edges(t(), (edge_value() -> edge_value())) :: t()

Applies function to every edge value in graph.

Link to this function

map_graph(graph, function)

View Source

Specs

map_graph(t(), (InductiveGraph.context() -> InductiveGraph.context())) :: t()

Applies function to every context in graph.

Link to this function

map_vertices(graph, function)

View Source

Specs

map_vertices(t(), (vertex_value() -> vertex_value())) :: t()

Applies function to every vertex value in graph.

Link to this function

map_vertices_and_edges(graph, vertex_function, edge_function)

View Source

Specs

map_vertices_and_edges(
  t(),
  (vertex_value() -> vertex_value()),
  (edge_value() -> edge_value())
) :: t()

Applies vertex_function to every vertex value and edge_function to every edge value in graph.

Link to this function

update_context(context, update_type, function)

View Source

Specs

update_context(
  context(),
  :context | :predecessors | :vertex_value | :successors,
  (context() -> context()) | (adjacents() -> adjacents()) | (value() -> value())
) :: context()

Updates context by function based on update_type.

Link to this section Conversion Functions

Link to this function

from_adjacents(adjacents)

View Source

Specs

from_adjacents(adjacents()) :: InductiveGraph.adjacents()

Converts adjacents to [{edge_value, neighbor}].

Link to this function

from_context(context, vertex)

View Source

Specs

from_context(context(), vertex()) :: InductiveGraph.context()

Converts context to {[{edge_value, neighbor}], vertex, vertex_value, [{edge_value, neighbor}]}.

Specs

to_adjacents(InductiveGraph.adjacents()) :: adjacents()

Converts [{edge_value, neighbor}] to adjacents.

Specs

to_context(InductiveGraph.context()) :: context()

Converts {[{edge_value, neighbor}], vertex, vertex_value, [{edge_value, neighbor}]} to context.

Link to this section Inspection Functions

Specs

count_vertices(t()) :: non_neg_integer()

Counts number of vertices in graph.

Specs

empty?(t()) :: boolean()

Determines if graph is empty.

Specs

has_edge?(t(), edge()) :: boolean()

Determines if edge is in graph.

Link to this function

has_vertex?(graph, vertex)

View Source

Specs

has_vertex?(t(), vertex()) :: boolean()

Determines if vertex is in graph.

Link to this function

list_tagged_edges(graph)

View Source

Specs

list_tagged_edges(t()) :: [tagged_edge()]

Lists all tagged edges in graph.

Link to this function

list_tagged_vertices(graph)

View Source

Specs

list_tagged_vertices(t()) :: [tagged_vertex()]

Lists all vertices in graph.

Link to this function

pretty_print(graph, count \\ -1)

View Source

Specs

pretty_print(t(), integer()) :: String.t()

Pretty prints inductive representation of graph.

If count is provided, then up to count number of contexts will be shown.

Specs

vertex_range(t()) :: {:ok, minimum :: integer(), maximum :: integer()} | :error

Gets range of vertex in graph.

Returns {:ok, minimum, maximum} for graphs with at least one vertex. Returns :error for empty graph.