PregelEx (PregelEx v0.1.3)

View Source

PregelEx - A Pregel-like graph processing framework for Elixir.

Supports multiple graphs with vertices that can perform distributed computation. Each graph runs as a separate supervisor tree with fault tolerance.

Summary

Functions

Clears all outgoing messages for a vertex in the specified graph.

Computes a vertex in the specified graph.

Creates an edge between two vertices in a graph.

Creates a new graph with the given ID.

Creates a vertex in the specified graph.

Executes a superstep for the given graph.

Gets the count of active graphs.

Gets the count of vertices in a graph.

Gets all outgoing edges for a vertex.

Gets all neighbor vertex IDs for a vertex.

Gets the state of a vertex in a graph.

Lists all edges in the graph.

Lists all active graphs.

Lists all vertices in a graph.

Removes an edge between two vertices.

Sends a message from one vertex to another in the specified graph.

Stops a graph and all its vertices.

Stops a vertex in the specified graph.

Functions

clear_outgoing_messages(graph_id, vertex_id)

Clears all outgoing messages for a vertex in the specified graph.

compute_vertex(graph_id, vertex_id)

Computes a vertex in the specified graph.

create_edge(graph_id, from_vertex_id, to_vertex_id, opts \\ [])

Creates an edge between two vertices in a graph.

Parameters

  • graph_id: The ID of the graph containing the vertices
  • from_vertex_id: The source vertex ID
  • to_vertex_id: The destination vertex ID
  • weight: The weight/cost of the edge (defaults to 1)
  • properties: Additional metadata for the edge (defaults to empty map)

Examples

{:ok, edge} = PregelEx.create_edge(graph_id, "vtx.abc", "vtx.def", 2.5)
{:ok, edge} = PregelEx.create_edge(graph_id, "vtx.abc", "vtx.def", 1, %{type: "friendship"})

create_graph(graph_id)

@spec create_graph(String.t()) :: {:ok, String.t(), pid()} | {:error, atom()}

Creates a new graph with the given ID.

create_vertex(graph_id, name, function, opts \\ [])

@spec create_vertex(String.t(), String.t(), (map() -> map()), keyword()) ::
  {:ok, String.t(), pid()} | {:error, atom()}

Creates a vertex in the specified graph.

execute_superstep(graph_id)

Executes a superstep for the given graph.

Parameters

  • graph_id: The identifier of the graph on which to execute the superstep.

Returns

  • The result of executing the superstep, as returned by Graph.execute_superstep/1.

get_final_value(graph_id)

get_graph_count()

Gets the count of active graphs.

get_vertex_count(graph_id)

Gets the count of vertices in a graph.

get_vertex_edges(graph_id, vertex_id)

Gets all outgoing edges for a vertex.

get_vertex_neighbors(graph_id, vertex_id)

Gets all neighbor vertex IDs for a vertex.

get_vertex_state(graph_id, vertex_id)

Gets the state of a vertex in a graph.

list_edges(graph_id)

Lists all edges in the graph.

list_graphs()

Lists all active graphs.

list_vertices(graph_id)

Lists all vertices in a graph.

remove_edge(graph_id, from_vertex_id, to_vertex_id)

Removes an edge between two vertices.

run(graph_id, opts \\ [])

send_message(graph_id, from_vertex_id, to_vertex_id, content)

Sends a message from one vertex to another in the specified graph.

stop_graph(graph_id)

Stops a graph and all its vertices.

stop_vertex(graph_id, vertex_id)

Stops a vertex in the specified graph.