Graphs¶
Ekratia uses Networkx library to operate with graphs. GraphEkratia is a class that extends from DiGraph and implements required methods for the Ekratia vote system.
-
class
ekratia.core.graphs.
GraphEkratia
(*args, **kwargs)¶ Extends Digraph Class to add methods used in the voting system.
How to use it:
graph = GraphEkratia() graph.add_user_id(1) graph.add_users_ids([1,2,3])
-
add_user_id
(user_id)¶ Add a nodes from user_id
Param: user_id User Id.
-
add_users_ids
(users_ids)¶ Adds nodes to the graph from a list of user ids
Param: list users_ids: List of user ids
-
attach_predecessors
(node)¶ Attach the predecessors of a node
Param: node Id.
-
attach_succesors
(node)¶ Attach the succesors of a node
Param: node Id.
-
get_pagerank_values
()¶ dictionary of pagerank values for the nodes of the graph
Param: user_id User Id. Returns: pagerank calculation Return type: dict
-
get_sigma_representation
()¶ Representation for Sigma JS library
Returns: dict of nodes and edges Return type: dict
-
get_user_id_delegates
(user_id)¶ returns a list of ids of succesors of the node
Param: user_id User Id. Returns: list of user ids Return type: list
-
get_user_id_delegates_to_me
(user_id)¶ returns a list of ids of predecessors of the node
Param: user_id User Id. Returns: list of user ids Return type: list
-
queue_node
(node)¶ Queue a node for future revision
Param: node Id.
-
retrieve_node
()¶ Retrieves a node from the queue
Returns: node Return type: int
-
set_exclude_list
(users_ids)¶ Excludes list of ids from the Graph
Parameters: users_ids (list) – List of users ids
-
visit_node
(node)¶ Add a nodes to visited list
Param: node Id.