<commit_before>

"""
Topological sorting
https://en.wikipedia.org/wiki/Topological_sorting
"""

from __future__ import print_function


class Graph(object):
    """ Simple implementation of directed acyclic graph

    graph : dict
            key: node, values: list of connected nodes
    """
    def __init__(self, nodes, dependencies):
        self.nodes = nodes
        self.dependencies = dependencies

    def __str__(self):
        """ string representation of the graph """
        string = ''
        for node in sorted(self.nodes):
            strnode = ["{} -> {}".format(start, end)
                       for start, end in self.dependencies if start == node]
            string += "node {}: {}\n".format(node, " ".join(strnode))<commit_msg>fix docs for Graph class in topological_sorting.py<commit_after>

"""
Topological sorting
https://en.wikipedia.org/wiki/Topological_sorting
"""

from __future__ import print_function


class Graph(object):
    """ Simple implementation of directed acyclic graph

    nodes : set
            set of all nodes in the graph
    dependencies : list
            list of tuples (node1, node2) which show connection
            between nodes of the graph
    """
    def __init__(self, nodes, dependencies):
        self.nodes = nodes
        self.dependencies = dependencies

    def __str__(self):
        """ string representation of the graph """
        string = ''
        for node in sorted(self.nodes):
            strnode = ["{} -> {}".format(start, end)
                       for start, end in self.dependencies if start == node]
            string += "node {}: {}\n".format(node, " ".join(strnode))
{'fraction_non_alphanumeric': 0.11231884057971014, 'fraction_numerical': 0.0012077294685990338, 'mean_word_length': 2.409465020576132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4199905', 'n_tokens_mistral': 441, 'n_tokens_neox': 424, 'n_words': 140}