MCPcopy Create free account
hub / github.com/effect-app/libs / connectedComponents

Function connectedComponents

repos/effect/packages/effect/src/Graph.ts:2924–2956  ·  view source on GitHub ↗
(
  graph: Graph<N, E, "undirected"> | MutableGraph<N, E, "undirected">
)

Source from the content-addressed store, hash-verified

2922): string => {
2923 const impl = graphImpl(graph)
2924 const {
2925 edgeLabel = (data: E) => String(data),
2926 graphName = "G",
2927 nodeLabel = (data: N) => String(data)
2928 } = options ?? {}
2929
2930 const isDirected = graph.type === "directed"
2931 const graphType = isDirected ? "digraph" : "graph"
2932 const edgeOperator = isDirected ? "->" : "--"
2933 const graphId = `"${escapeGraphVizString(graphName)}"`
2934
2935 const lines: Array<string> = []
2936 lines.push(`${graphType} ${graphId} {`)
2937
2938 // Add nodes
2939 for (const [nodeIndex, nodeData] of impl.nodes) {
2940 const label = escapeGraphVizString(nodeLabel(nodeData))
2941 lines.push(` "${nodeIndex}" [label="${label}"];`)
2942 }
2943
2944 // Add edges
2945 for (const [, edgeData] of impl.edges) {
2946 const label = escapeGraphVizString(edgeLabel(edgeData.data))
2947 lines.push(` "${edgeData.source}" ${edgeOperator} "${edgeData.target}" [label="${label}"];`)
2948 }
2949
2950 lines.push("}")
2951 return lines.join("\n")
2952})
2953
2954// =============================================================================
2955// Mermaid Export
2956// =============================================================================
2957
2958/**
2959 * Mermaid node shape types for diagram visualization.

Callers

nothing calls this directly

Calls 4

getUndirectedNeighborsFunction · 0.85
pushMethod · 0.80
addMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…