ch5ex11

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: GPL-3.0 Imports: 0 Imported by: 0

README

= Exercise 5.11
// Refs:
:url-base: https://github.com/fenegroni/TGPL-exercise-solutions
:workflow: workflows/Exercise 5.11
:action: actions/workflows/ch5ex11.yml
:url-workflow: {url-base}/{workflow}
:url-action: {url-base}/{action}
:badge-exercise: image:{url-workflow}/badge.svg?branch=main[link={url-action}]

{badge-exercise}

The instructor of the _linear algebra_ course decides that
_calculus_ is now a prerequisite.
Extend the `topoSort` function to report cycles.

== Test

In validating the list produced by `topoSort`
in _Exercise 5.10_, we accidentally figured out
how to detect a cycle in a graph.

We add a new test `TestTopoSortCyclicGraph`
which errors if `topoSort` fails to detect a cyclic graph,
on top of all the checks we already performed
in _Exercise 5.10_.

The new `topoSort` implements
uses an additional map `dependents`
to detect cyclic dependencies and
returns an error if the graph has a cycle.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopoSort

func TopoSort(g graph) (order []string, ok bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL