<commit_before>---
title: "Testing the display of code with different type of highlighting"
excerpt: This post shows code highlighting
---

In this post I am going to write some code, and then at some point, I will update the _sass/_syntax.css to update the highlight schema that is used here.

The following code snipped is highlighted using Rouge:
```python
def topological_sort(self):
    """
    Creates a linear order of the nodes such that u appears before v in the linear order if v depends on u (so that
    (u,v) is an edge in the graph.
    :return:
    """
    sorted_graph = []
    unsorted_graph = self.get_unsorted_graph()
    nodes = set([node for node in unsorted_graph.keys()])

    # Create dictionary: node : number of in-degrees
    in_degree = {}
    for node, edges in self.get_unsorted_graph().items():
        in_degree[node] = len(edges)

    next_node = [node for node in in_degree if in_degree[node] == 0]

    while next_node:
        current = next_node.pop(0)
        nodes.remove(current)
        sorted_graph.append(current)

        # Find all the nodes that are adjacent to current: nodes that have current in one of their edges
        for vertex in nodes:
            if current in unsorted_graph[vertex]:
                in_degree[vertex] -= 1
                if in_degree[vertex] == 0:
                    next_node.append(vertex)

    return sorted_graph
```

The following is highlighted using the Pygments highlighter native to Jekyll:
{% highlight python %}
def build_unsorted_graph(self):
    # Given the nodes, create an unsorted graph with has the list of nodes and all the vertices they are tied to

    interim = {}
    for node in self.nodes:
        # dependencies are the list of nodes that need to be started before current node is started
        # so in a graph, the dependencies would be incoming arrows that go to the current node
        if node not in interim:
            interim[node] = node.dependencies

    self.set_unsorted_graph(interim)
    return interim
{% highlight %}<commit_msg>Fixing closing tag for highlight<commit_after>---
title: "Testing the display of code with different type of highlighting"
excerpt: This post shows code highlighting
tags: [highlight, rouge]
---

In this post I am going to write some code, and then at some point, I will update the _sass/_syntax.css to update the highlight schema that is used here.

The following code snipped is highlighted using Rouge:
```python
def topological_sort(self):
    """
    Creates a linear order of the nodes such that u appears before v in the linear order if v depends on u (so that
    (u,v) is an edge in the graph.
    :return:
    """
    sorted_graph = []
    unsorted_graph = self.get_unsorted_graph()
    nodes = set([node for node in unsorted_graph.keys()])

    # Create dictionary: node : number of in-degrees
    in_degree = {}
    for node, edges in self.get_unsorted_graph().items():
        in_degree[node] = len(edges)

    next_node = [node for node in in_degree if in_degree[node] == 0]

    while next_node:
        current = next_node.pop(0)
        nodes.remove(current)
        sorted_graph.append(current)

        # Find all the nodes that are adjacent to current: nodes that have current in one of their edges
        for vertex in nodes:
            if current in unsorted_graph[vertex]:
                in_degree[vertex] -= 1
                if in_degree[vertex] == 0:
                    next_node.append(vertex)

    return sorted_graph
```

The following is highlighted using the Pygments highlighter native to Jekyll:
{% highlight python %}
def build_unsorted_graph(self):
    # Given the nodes, create an unsorted graph with has the list of nodes and all the vertices they are tied to

    interim = {}
    for node in self.nodes:
        # dependencies are the list of nodes that need to be started before current node is started
        # so in a graph, the dependencies would be incoming arrows that go to the current node
        if node not in interim:
            interim[node] = node.dependencies

    self.set_unsorted_graph(interim)
    return interim
{% endhighlight %}
{'fraction_non_alphanumeric': 0.06951484431571325, 'fraction_numerical': 0.0019309678976587015, 'mean_word_length': 2.872897196261682, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6793940', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1103, 'n_words': 499}