tfgraph.algorithms.pagerank.transition¶
tfgraph.algorithms.pagerank.transition Module
This module contains a set of classes that represents the transition matrix of a graph, that is used in PageRank algorithms.
Transition¶
-
class
tfgraph.algorithms.pagerank.transition.transition.
Transition
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Transition Base Class
This class acts as base class of transition behavior between vertices of the graph. This class is used to use as base type that provides this functionality and also to store the common attributes that uses all Transition implementations.
The heiress classes need to implement the get_tf() method that provides the transitions.
-
sess
¶ tf.Session
– This attribute represents the session that runs the TensorFlow operations.
-
name
¶ str – This attribute represents the name of the object in TensorFlow’s op Graph.
-
writer
¶ tf.summary.FileWriter
– This attribute represents a TensorFlow’s Writer, that is used to obtain stats.
-
is_sparse
¶ bool – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
-
G
¶ tfgraph.Graph
– The graph on which the transition is referred.
-
__init__
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Constructor of the class.
This method is called to create a new instance of Transition class.
Parameters: - sess (
tf.Session
) – This attribute represents the session that runs the TensorFlow operations. - name (str) – This attribute represents the name of the object in TensorFlow’s op Graph.
- graph (
tfgraph.Graph
) – The graph on which the transition is referred. - writer (
tf.summary.FileWriter
) – This attribute represents a TensorFlow’s Writer, that is used to obtain stats. - is_sparse (bool) – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
- sess (
-
get_tf
(*args, **kwargs)[source]¶ The method that returns the transition Tensor.
This method will return the transition matrix of the graph.
Parameters: - *args – The args of the get_tf() method.
- **kwargs – The kwargs of the get_tf() method.
Returns: - A tf.Tensor that contains the distribution of
transitions over vertices of the graph.
Return type: (
tf.Tensor
)
-
TransitionMatrix¶
-
class
tfgraph.algorithms.pagerank.transition.transition_matrix.
TransitionMatrix
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Transition Matrix Class
This class implements the functionality of a 2-D matrix that represents the probability distribution of walk between the vertices of the graph.
-
sess
¶ tf.Session
– This attribute represents the session that runs the TensorFlow operations.
-
name
¶ str – This attribute represents the name of the object in TensorFlow’s op Graph.
-
writer
¶ tf.summary.FileWriter
– This attribute represents a TensorFlow’s Writer, that is used to obtain stats.
-
is_sparse
¶ bool – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
-
G
¶ tfgraph.Graph
– The graph on which the transition is referred.
-
transition
¶ tf.Variable
– The 2-D tf.Tensor with the same shape as adjacency matrix of the graph, that represents the probabilities to move from one vertex to another.
-
__init__
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Constructor of the class.
This method is called to create a new instance of Transition class.
Parameters: - sess (
tf.Session
) – This attribute represents the session that runs the TensorFlow operations. - name (str) – This attribute represents the name of the object in TensorFlow’s op Graph.
- graph (
tfgraph.Graph
) – The graph on which the transition is referred. - writer (
tf.summary.FileWriter
) – This attribute represents a TensorFlow’s Writer, that is used to obtain stats. - is_sparse (bool) – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
- sess (
-
get_tf
(*args, **kwargs)[source]¶ The method that returns the transition Tensor.
This method will return the transition matrix of the graph.
Parameters: - *args – The args of the get_tf() method.
- **kwargs – The kwargs of the get_tf() method.
Returns: - A tf.Tensor that contains the distribution of
transitions over vertices of the graph.
Return type: (
tf.Tensor
)
-
update_edge
(edge: numpy.ndarray, change: float) → None[source]¶ The callback to receive notifications about edge changes in the graph.
This method is called from the Graph when an addition or deletion is produced on the edge set. So probably is necessary to recompute the transition matrix.
Parameters: - edge (
np.ndarray
) – A 1-D np.ndarray that represents the edge that changes in the graph, where edge[0] is the source vertex, and edge[1] the destination vertex. - change (float) – The variation of the edge weight. If the final value is 0.0 then the edge is removed.
Returns: This method returns nothing.
- edge (
-
TransitionResetMatrix¶
-
class
tfgraph.algorithms.pagerank.transition.transition_reset_matrix.
TransitionResetMatrix
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, beta: float, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Transition Matrix Class
This class implements the functionality of a 2-D matrix that represents the probability distribution of walk between the vertices of the graph.
-
sess
¶ tf.Session
– This attribute represents the session that runs the TensorFlow operations.
-
name
¶ str – This attribute represents the name of the object in TensorFlow’s op Graph.
-
writer
¶ tf.summary.FileWriter
– This attribute represents a TensorFlow’s Writer, that is used to obtain stats.
-
is_sparse
¶ bool – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
-
G
¶ tfgraph.Graph
– The graph on which the transition is referred.
-
transition
¶ tf.Variable
– The 2-D tf.Tensor with the same shape as adjacency matrix of the graph, that represents the probabilities to move from one vertex to another.
-
beta
¶ float – The reset probability of the random walks, i.e. the probability that a user that surfs the graph an decides to jump to another vertex not connected to the current.
-
__init__
(sess: tensorflow.python.client.session.Session, name: str, graph: tfgraph.graph.graph.Graph, beta: float, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ Constructor of the class.
This method is called to create a new instance of Transition class.
Parameters: - sess (
tf.Session
) – This attribute represents the session that runs the TensorFlow operations. - name (str) – This attribute represents the name of the object in TensorFlow’s op Graph.
- graph (
tfgraph.Graph
) – The graph on which the transition is referred. - beta (float) – The reset probability of the random walks, i.e. the probability that a user that surfs the graph an decides to jump to another vertex not connected to the current.
- writer (
tf.summary.FileWriter
) – This attribute represents a TensorFlow’s Writer, that is used to obtain stats. - is_sparse (bool) – Use sparse Tensors if it’s set to True. Not implemented yet. Show the Todo.
- sess (
-
get_tf
(*args, **kwargs)[source]¶ The method that returns the transition Tensor.
This method will return the transition matrix of the graph.
Parameters: - *args – The args of the get_tf() method.
- **kwargs – The kwargs of the get_tf() method.
Returns: - A tf.Tensor that contains the distribution of
transitions over vertices of the graph.
Return type: (
tf.Tensor
)
-
update_edge
(edge: numpy.ndarray, change: float) → None[source]¶ The callback to receive notifications about edge changes in the graph.
This method is called from the Graph when an addition or deletion is produced on the edge set. So probably is necessary to recompute the transition matrix.
Parameters: - edge (
np.ndarray
) – A 1-D np.ndarray that represents the edge that changes in the graph, where edge[0] is the source vertex, and edge[1] the destination vertex. - change (float) – The variation of the edge weight. If the final value is 0.0 then the edge is removed.
Returns: This method returns nothing.
- edge (
-