View Source Bonfire.Social.Graph (Bonfire v0.9.10-classic-beta.169)
An extension for Bonfire that handles:
- Following
- Follow Requests
- Social graph analysis
Handy commands
Copyright and License
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
.
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.
Calculates the distance between two nodes in the graph.
Examples
iex> Bonfire.Social.Graph.graph_distance("subject_id", "object_id")
{:ok, length}
Retrieves distances from a given subject to all other nodes.
Examples
iex> Bonfire.Social.Graph.graph_distances("subject_id")
[{id, length}]
Executes a query on the graph database.
Examples
iex> Bonfire.Social.Graph.graph_query("MATCH (n) RETURN n")
{:ok, result}
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.