From 66bb188d9d8846c8f299675a8b822947043a9a6b Mon Sep 17 00:00:00 2001 From: Armin Primadi Date: Thu, 1 Jun 2023 12:20:25 +0700 Subject: [PATCH] Update documentation --- graph_algorithm.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/graph_algorithm.js b/graph_algorithm.js index fecd68f..091216e 100644 --- a/graph_algorithm.js +++ b/graph_algorithm.js @@ -4,17 +4,20 @@ var BLACK = 2 var GraphAlgorithm = { - // - // Detect loop in a directed graph, use graph coloring algorithm. - // - // @param vertices - array of vertices, a vertex is either an integer or a - // string - // @param edges - array of edges, an edge is an array of length 2 which - // marks the source and destination vertice. - // i.e., [source, dest] - // - // @return { hasLoop: true, loop: [...] } - // + /** + * Detects loops in a directed graph using a graph coloring algorithm. + * + * @param {Array} vertices - An array of vertices. Each vertex can be either + * an integer or a string. + * @param {Array} edges - An array of edges. Each edge is represented as an array of length 2, + * specifying the source and destination vertices. Format: [source, destination]. + * + * @returns {Object} An object indicating whether a loop is present and, if so, the vertices + * forming the loop. The return value has the following structure: + * - hasLoop: A boolean value indicating whether a loop is present in the graph. + * - loop: An array of vertices forming the loop, listed in the order they are encountered + * during traversal. + */ hasLoop: function(vertices, edges) { var colors = {} var path = [] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy