View Source Bonfire.Social.Graph (Bonfire v0.9.10-classic-beta.156)

An extension for Bonfire that handles:

  • Following
  • Follow Requests
  • Social graph analysis

Handy commands

Copyright (c) 2023 Bonfire Contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Summary

Functions

Returns a specification to start this module under a supervisor.

Adds a relationship to the graph.

Clears the graph database by deleting all nodes and relationships. Use with care!

Retrieves the graph DB connection.

Calculates the distance between two nodes in the graph.

Retrieves distances from a given subject to all other nodes.

Executes a query on the graph database.

Removes a relationship from the graph.

Initializes the GenServer and calls init_and_load/0

Initializes the graph DB and calls load_from_db/0

Loads follows from the SQL DB and stores them the in-memory graph DB.

Retrieves the possible applications to be started based on configuration.

Starts the GenServer link.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

graph_add(subject, object, type)

View Source

Adds a relationship to the graph.

Examples

iex> Bonfire.Social.Graph.graph_add("subject_id", "object_id", "type")
:ok

Clears the graph database by deleting all nodes and relationships. Use with care!

Examples

iex> Bonfire.Social.Graph.graph_clear()
:ok

Retrieves the graph DB connection.

Link to this function

graph_distance(subject, object)

View Source

Calculates the distance between two nodes in the graph.

Examples

iex> Bonfire.Social.Graph.graph_distance("subject_id", "object_id")
{:ok, length}
Link to this function

graph_distances(subject)

View Source

Retrieves distances from a given subject to all other nodes.

Examples

iex> Bonfire.Social.Graph.graph_distances("subject_id")
[{id, length}]
Link to this function

graph_query(graph_conn \\ graph_conn(), query)

View Source

Executes a query on the graph database.

Examples

iex> Bonfire.Social.Graph.graph_query("MATCH (n) RETURN n")
{:ok, result}
Link to this function

graph_remove(subject, object, type)

View Source

Removes a relationship from the graph.

Examples

iex> Bonfire.Social.Graph.graph_remove("subject_id", "object_id", "type")
:ok

Initializes the GenServer and calls init_and_load/0

Initializes the graph DB and calls load_from_db/0

Loads follows from the SQL DB and stores them the in-memory graph DB.

Retrieves the possible applications to be started based on configuration.

Returns a list of OTP applications (including the Bolt.Sips Neo4j driver to connect to the graph database) or an empty list if disabled.

Starts the GenServer link.