tf_G.utils¶
tf_G.utils Module
It contains a set of utilities that is used for another classes of tf_G module.
DataSets¶

class
tf_G.utils.datasets.
DataSets
[source]¶ DataSets class represents some data sets included in the package.
The class provides compose_from_path method to import personal sets.

static
compose_from_path
(path: str, index_decrement: bool) → numpy.ndarray[source]¶ This method generates a data set from a given path.
The method obtains the data from the given path, then decrements its values if is necessary and permutes the resulting data set.
The decrement option is offered because of in some cases the data set treats the initial node as 1 but many data structures in python are 0indexed, so decrementing the values improves space performance.
Parameters: Returns: The data set that represents the Graph.
Return type: (
np.ndarray
)

static
naive_4
() → numpy.ndarray[source]¶ This method returns the naive_4 data set.
The data set is obtained from Cornell University guide lecture of PageRank algorithm.
This graph contains 4 vertices and 8 edges.
Returns: The data set that represents the Graph. Return type: ( np.ndarray
)

static
naive_6
() → numpy.ndarray[source]¶ This method returns the naive_6 data set.
The data set is obtained from mathworks study of PageRank algorithm.
This graph contains 6 vertices and 9 edges.
 Url:
 https://www.mathworks.com/content/dam/mathworks/mathworksdotcom/moler/exm/chapters/pagerank.pdf
Returns: The data set that represents the Graph. Return type: ( np.ndarray
)

static
TensorFlowObject¶

class
tf_G.utils.tensorflow_object.
TensorFlowObject
(sess: tensorflow.python.client.session.Session, name: str, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ This class gives represents a TensorFlow object in the package.
It acts as Parent class of many classes that uses the TensorFlow library and needs to execute code, so it’s necessary to have a session and other attributes.

__init__
(sess: tensorflow.python.client.session.Session, name: str, writer: tensorflow.python.summary.writer.writer.FileWriter = None, is_sparse: bool = False) → None[source]¶ The constructor of class.
It assign the input parameters to the class objects and no more.
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.
 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.
Todo
 Implement variables as sparse when it’s possible. Waiting to TensorFlow for it.
 sess (

Utils¶

class
tf_G.utils.utils.
Utils
[source]¶ Utils class of the tf_G package.
This class contains static methods that will be used by another classes around the package.

static
ranked
(x: numpy.ndarray) → numpy.ndarray[source]¶ This method sorts the array indices given by its values.
It can be used to generate a ranking based on the values of an array in which the value represents the score and the index the object identifier.
Parameters: x ( np.ndarray
) – A 2D np.ndarray to rank the results by rows.Returns:  An array containing the indices of the input array
 sorted in decremental order.
Return type: ( np.ndarray
)

static
save_ranks
(filename: str, array: numpy.ndarray, index_increment: bool = True) → None[source]¶ This method will save the input array in the filesystem.
The method creates a file in the filesystem with name filename and puts the array content inside it.
This method provides the index_increment that increments the first column by one if True. The reason of this option is that the method is created to store results of graph operations, and in some cases the graph vertices is represented as 0indexed and anothers as 1indexed.
Parameters: Returns: This method returns nothing.

static