@lzehrung/codegraph 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +448 -0
- package/THIRD_PARTY_NOTICES +77 -0
- package/codegraph-skill/codegraph/SKILL.md +262 -0
- package/dist/agent/artifact.d.ts +65 -0
- package/dist/agent/artifact.d.ts.map +1 -0
- package/dist/agent/artifact.js +616 -0
- package/dist/agent/artifact.js.map +1 -0
- package/dist/agent/bounds.d.ts +12 -0
- package/dist/agent/bounds.d.ts.map +1 -0
- package/dist/agent/bounds.js +25 -0
- package/dist/agent/bounds.js.map +1 -0
- package/dist/agent/callHierarchy.d.ts +28 -0
- package/dist/agent/callHierarchy.d.ts.map +1 -0
- package/dist/agent/callHierarchy.js +82 -0
- package/dist/agent/callHierarchy.js.map +1 -0
- package/dist/agent/explain.d.ts +136 -0
- package/dist/agent/explain.d.ts.map +1 -0
- package/dist/agent/explain.js +743 -0
- package/dist/agent/explain.js.map +1 -0
- package/dist/agent/explore.d.ts +67 -0
- package/dist/agent/explore.d.ts.map +1 -0
- package/dist/agent/explore.js +474 -0
- package/dist/agent/explore.js.map +1 -0
- package/dist/agent/fileView.d.ts +55 -0
- package/dist/agent/fileView.d.ts.map +1 -0
- package/dist/agent/fileView.js +528 -0
- package/dist/agent/fileView.js.map +1 -0
- package/dist/agent/followUps.d.ts +9 -0
- package/dist/agent/followUps.d.ts.map +1 -0
- package/dist/agent/followUps.js +164 -0
- package/dist/agent/followUps.js.map +1 -0
- package/dist/agent/handles.d.ts +29 -0
- package/dist/agent/handles.d.ts.map +1 -0
- package/dist/agent/handles.js +103 -0
- package/dist/agent/handles.js.map +1 -0
- package/dist/agent/normalize.d.ts +19 -0
- package/dist/agent/normalize.d.ts.map +1 -0
- package/dist/agent/normalize.js +45 -0
- package/dist/agent/normalize.js.map +1 -0
- package/dist/agent/orient.d.ts +55 -0
- package/dist/agent/orient.d.ts.map +1 -0
- package/dist/agent/orient.js +307 -0
- package/dist/agent/orient.js.map +1 -0
- package/dist/agent/packet.d.ts +28 -0
- package/dist/agent/packet.d.ts.map +1 -0
- package/dist/agent/packet.js +138 -0
- package/dist/agent/packet.js.map +1 -0
- package/dist/agent/query-index/candidates.d.ts +4 -0
- package/dist/agent/query-index/candidates.d.ts.map +1 -0
- package/dist/agent/query-index/candidates.js +89 -0
- package/dist/agent/query-index/candidates.js.map +1 -0
- package/dist/agent/query-index/content.d.ts +36 -0
- package/dist/agent/query-index/content.d.ts.map +1 -0
- package/dist/agent/query-index/content.js +124 -0
- package/dist/agent/query-index/content.js.map +1 -0
- package/dist/agent/query-index/paths.d.ts +12 -0
- package/dist/agent/query-index/paths.d.ts.map +1 -0
- package/dist/agent/query-index/paths.js +41 -0
- package/dist/agent/query-index/paths.js.map +1 -0
- package/dist/agent/query-index/queryIndexWorker.d.ts +8 -0
- package/dist/agent/query-index/queryIndexWorker.d.ts.map +1 -0
- package/dist/agent/query-index/queryIndexWorker.js +11 -0
- package/dist/agent/query-index/queryIndexWorker.js.map +1 -0
- package/dist/agent/query-index/schema.d.ts +26 -0
- package/dist/agent/query-index/schema.d.ts.map +1 -0
- package/dist/agent/query-index/schema.js +171 -0
- package/dist/agent/query-index/schema.js.map +1 -0
- package/dist/agent/query-index/sessionStore.d.ts +5 -0
- package/dist/agent/query-index/sessionStore.d.ts.map +1 -0
- package/dist/agent/query-index/sessionStore.js +53 -0
- package/dist/agent/query-index/sessionStore.js.map +1 -0
- package/dist/agent/query-index/sourceIdentity.d.ts +3 -0
- package/dist/agent/query-index/sourceIdentity.d.ts.map +1 -0
- package/dist/agent/query-index/sourceIdentity.js +12 -0
- package/dist/agent/query-index/sourceIdentity.js.map +1 -0
- package/dist/agent/query-index/store.d.ts +48 -0
- package/dist/agent/query-index/store.d.ts.map +1 -0
- package/dist/agent/query-index/store.js +372 -0
- package/dist/agent/query-index/store.js.map +1 -0
- package/dist/agent/query-index/update.d.ts +9 -0
- package/dist/agent/query-index/update.d.ts.map +1 -0
- package/dist/agent/query-index/update.js +309 -0
- package/dist/agent/query-index/update.js.map +1 -0
- package/dist/agent/query-index/workerPool.d.ts +5 -0
- package/dist/agent/query-index/workerPool.d.ts.map +1 -0
- package/dist/agent/query-index/workerPool.js +82 -0
- package/dist/agent/query-index/workerPool.js.map +1 -0
- package/dist/agent/refactorPlan.d.ts +40 -0
- package/dist/agent/refactorPlan.d.ts.map +1 -0
- package/dist/agent/refactorPlan.js +234 -0
- package/dist/agent/refactorPlan.js.map +1 -0
- package/dist/agent/renamePreview.d.ts +60 -0
- package/dist/agent/renamePreview.d.ts.map +1 -0
- package/dist/agent/renamePreview.js +1008 -0
- package/dist/agent/renamePreview.js.map +1 -0
- package/dist/agent/search.d.ts +77 -0
- package/dist/agent/search.d.ts.map +1 -0
- package/dist/agent/search.js +1002 -0
- package/dist/agent/search.js.map +1 -0
- package/dist/agent/semantic.d.ts +35 -0
- package/dist/agent/semantic.d.ts.map +1 -0
- package/dist/agent/semantic.js +2 -0
- package/dist/agent/semantic.js.map +1 -0
- package/dist/agent/semanticSymbols.d.ts +16 -0
- package/dist/agent/semanticSymbols.d.ts.map +1 -0
- package/dist/agent/semanticSymbols.js +96 -0
- package/dist/agent/semanticSymbols.js.map +1 -0
- package/dist/agent/session.d.ts +71 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +432 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/sessionLifecycle.d.ts +5 -0
- package/dist/agent/sessionLifecycle.d.ts.map +1 -0
- package/dist/agent/sessionLifecycle.js +18 -0
- package/dist/agent/sessionLifecycle.js.map +1 -0
- package/dist/agent/shell.d.ts +2 -0
- package/dist/agent/shell.d.ts.map +1 -0
- package/dist/agent/shell.js +6 -0
- package/dist/agent/shell.js.map +1 -0
- package/dist/agent/symbolLookup.d.ts +12 -0
- package/dist/agent/symbolLookup.d.ts.map +1 -0
- package/dist/agent/symbolLookup.js +26 -0
- package/dist/agent/symbolLookup.js.map +1 -0
- package/dist/agent/typeHierarchy.d.ts +39 -0
- package/dist/agent/typeHierarchy.d.ts.map +1 -0
- package/dist/agent/typeHierarchy.js +125 -0
- package/dist/agent/typeHierarchy.js.map +1 -0
- package/dist/agent/workspaceSymbols.d.ts +18 -0
- package/dist/agent/workspaceSymbols.d.ts.map +1 -0
- package/dist/agent/workspaceSymbols.js +75 -0
- package/dist/agent/workspaceSymbols.js.map +1 -0
- package/dist/agent-tools.d.ts +280 -0
- package/dist/agent-tools.d.ts.map +1 -0
- package/dist/agent-tools.js +669 -0
- package/dist/agent-tools.js.map +1 -0
- package/dist/agent.d.ts +35 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +19 -0
- package/dist/agent.js.map +1 -0
- package/dist/analysisSummary.d.ts +19 -0
- package/dist/analysisSummary.d.ts.map +1 -0
- package/dist/analysisSummary.js +80 -0
- package/dist/analysisSummary.js.map +1 -0
- package/dist/bin/cli.js +105144 -0
- package/dist/bin/queryIndexWorker.js +3914 -0
- package/dist/bootstrap/treeSitterLanguages.d.ts +5 -0
- package/dist/bootstrap/treeSitterLanguages.d.ts.map +1 -0
- package/dist/bootstrap/treeSitterLanguages.js +41 -0
- package/dist/bootstrap/treeSitterLanguages.js.map +1 -0
- package/dist/chunking/chunkBlocks.d.ts +9 -0
- package/dist/chunking/chunkBlocks.d.ts.map +1 -0
- package/dist/chunking/chunkBlocks.js +60 -0
- package/dist/chunking/chunkBlocks.js.map +1 -0
- package/dist/chunking/chunkFile.d.ts +34 -0
- package/dist/chunking/chunkFile.d.ts.map +1 -0
- package/dist/chunking/chunkFile.js +153 -0
- package/dist/chunking/chunkFile.js.map +1 -0
- package/dist/chunking/chunkId.d.ts +7 -0
- package/dist/chunking/chunkId.d.ts.map +1 -0
- package/dist/chunking/chunkId.js +30 -0
- package/dist/chunking/chunkId.js.map +1 -0
- package/dist/chunking/chunkMatches.d.ts +4 -0
- package/dist/chunking/chunkMatches.d.ts.map +1 -0
- package/dist/chunking/chunkMatches.js +65 -0
- package/dist/chunking/chunkMatches.js.map +1 -0
- package/dist/chunking/chunkMerge.d.ts +4 -0
- package/dist/chunking/chunkMerge.d.ts.map +1 -0
- package/dist/chunking/chunkMerge.js +144 -0
- package/dist/chunking/chunkMerge.js.map +1 -0
- package/dist/chunking/chunkSFC.d.ts +18 -0
- package/dist/chunking/chunkSFC.d.ts.map +1 -0
- package/dist/chunking/chunkSFC.js +165 -0
- package/dist/chunking/chunkSFC.js.map +1 -0
- package/dist/chunking/chunkSplit.d.ts +6 -0
- package/dist/chunking/chunkSplit.d.ts.map +1 -0
- package/dist/chunking/chunkSplit.js +170 -0
- package/dist/chunking/chunkSplit.js.map +1 -0
- package/dist/chunking/chunkTextFile.d.ts +28 -0
- package/dist/chunking/chunkTextFile.d.ts.map +1 -0
- package/dist/chunking/chunkTextFile.js +107 -0
- package/dist/chunking/chunkTextFile.js.map +1 -0
- package/dist/chunking/languageConfig.d.ts +35 -0
- package/dist/chunking/languageConfig.d.ts.map +1 -0
- package/dist/chunking/languageConfig.js +24 -0
- package/dist/chunking/languageConfig.js.map +1 -0
- package/dist/chunking/tokenizer.d.ts +2 -0
- package/dist/chunking/tokenizer.d.ts.map +1 -0
- package/dist/chunking/tokenizer.js +6 -0
- package/dist/chunking/tokenizer.js.map +1 -0
- package/dist/chunking/types.d.ts +54 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/chunking/types.js +2 -0
- package/dist/chunking/types.js.map +1 -0
- package/dist/cli/affected.d.ts +32 -0
- package/dist/cli/affected.d.ts.map +1 -0
- package/dist/cli/affected.js +235 -0
- package/dist/cli/affected.js.map +1 -0
- package/dist/cli/artifact.d.ts +4 -0
- package/dist/cli/artifact.d.ts.map +1 -0
- package/dist/cli/artifact.js +35 -0
- package/dist/cli/artifact.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +3 -0
- package/dist/cli/bootstrap.d.ts.map +1 -0
- package/dist/cli/bootstrap.js +8 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/callHierarchy.d.ts +6 -0
- package/dist/cli/callHierarchy.d.ts.map +1 -0
- package/dist/cli/callHierarchy.js +65 -0
- package/dist/cli/callHierarchy.js.map +1 -0
- package/dist/cli/chunk.d.ts +4 -0
- package/dist/cli/chunk.d.ts.map +1 -0
- package/dist/cli/chunk.js +109 -0
- package/dist/cli/chunk.js.map +1 -0
- package/dist/cli/commandCatalog.d.ts +14 -0
- package/dist/cli/commandCatalog.d.ts.map +1 -0
- package/dist/cli/commandCatalog.js +109 -0
- package/dist/cli/commandCatalog.js.map +1 -0
- package/dist/cli/commandTable.d.ts +16 -0
- package/dist/cli/commandTable.d.ts.map +1 -0
- package/dist/cli/commandTable.js +716 -0
- package/dist/cli/commandTable.js.map +1 -0
- package/dist/cli/compileCache.d.ts +17 -0
- package/dist/cli/compileCache.d.ts.map +1 -0
- package/dist/cli/compileCache.js +63 -0
- package/dist/cli/compileCache.js.map +1 -0
- package/dist/cli/context.d.ts +87 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +322 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/discoveryGlobs.d.ts +11 -0
- package/dist/cli/discoveryGlobs.d.ts.map +1 -0
- package/dist/cli/discoveryGlobs.js +74 -0
- package/dist/cli/discoveryGlobs.js.map +1 -0
- package/dist/cli/doctor.d.ts +33 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +143 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/drift.d.ts +18 -0
- package/dist/cli/drift.d.ts.map +1 -0
- package/dist/cli/drift.js +101 -0
- package/dist/cli/drift.js.map +1 -0
- package/dist/cli/duplicateSimilarity.d.ts +10 -0
- package/dist/cli/duplicateSimilarity.d.ts.map +1 -0
- package/dist/cli/duplicateSimilarity.js +20 -0
- package/dist/cli/duplicateSimilarity.js.map +1 -0
- package/dist/cli/duplicates.d.ts +15 -0
- package/dist/cli/duplicates.d.ts.map +1 -0
- package/dist/cli/duplicates.js +400 -0
- package/dist/cli/duplicates.js.map +1 -0
- package/dist/cli/explain.d.ts +4 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +47 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/explore.d.ts +4 -0
- package/dist/cli/explore.d.ts.map +1 -0
- package/dist/cli/explore.js +28 -0
- package/dist/cli/explore.js.map +1 -0
- package/dist/cli/file.d.ts +4 -0
- package/dist/cli/file.d.ts.map +1 -0
- package/dist/cli/file.js +53 -0
- package/dist/cli/file.js.map +1 -0
- package/dist/cli/graph.d.ts +90 -0
- package/dist/cli/graph.d.ts.map +1 -0
- package/dist/cli/graph.js +379 -0
- package/dist/cli/graph.js.map +1 -0
- package/dist/cli/graphDelta.d.ts +24 -0
- package/dist/cli/graphDelta.d.ts.map +1 -0
- package/dist/cli/graphDelta.js +75 -0
- package/dist/cli/graphDelta.js.map +1 -0
- package/dist/cli/graphQueries.d.ts +23 -0
- package/dist/cli/graphQueries.d.ts.map +1 -0
- package/dist/cli/graphQueries.js +257 -0
- package/dist/cli/graphQueries.js.map +1 -0
- package/dist/cli/grep.d.ts +10 -0
- package/dist/cli/grep.d.ts.map +1 -0
- package/dist/cli/grep.js +61 -0
- package/dist/cli/grep.js.map +1 -0
- package/dist/cli/help.d.ts +52 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +749 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/impact.d.ts +24 -0
- package/dist/cli/impact.d.ts.map +1 -0
- package/dist/cli/impact.js +481 -0
- package/dist/cli/impact.js.map +1 -0
- package/dist/cli/index.d.ts +43 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +112 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/indexPolicy.d.ts +36 -0
- package/dist/cli/indexPolicy.d.ts.map +1 -0
- package/dist/cli/indexPolicy.js +168 -0
- package/dist/cli/indexPolicy.js.map +1 -0
- package/dist/cli/inspect.d.ts +30 -0
- package/dist/cli/inspect.d.ts.map +1 -0
- package/dist/cli/inspect.js +323 -0
- package/dist/cli/inspect.js.map +1 -0
- package/dist/cli/install.d.ts +14 -0
- package/dist/cli/install.d.ts.map +1 -0
- package/dist/cli/install.js +273 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/invocationContext.d.ts +77 -0
- package/dist/cli/invocationContext.d.ts.map +1 -0
- package/dist/cli/invocationContext.js +357 -0
- package/dist/cli/invocationContext.js.map +1 -0
- package/dist/cli/lifecycle.d.ts +11 -0
- package/dist/cli/lifecycle.d.ts.map +1 -0
- package/dist/cli/lifecycle.js +81 -0
- package/dist/cli/lifecycle.js.map +1 -0
- package/dist/cli/links.d.ts +11 -0
- package/dist/cli/links.d.ts.map +1 -0
- package/dist/cli/links.js +53 -0
- package/dist/cli/links.js.map +1 -0
- package/dist/cli/location.d.ts +5 -0
- package/dist/cli/location.d.ts.map +1 -0
- package/dist/cli/location.js +11 -0
- package/dist/cli/location.js.map +1 -0
- package/dist/cli/mcp.d.ts +7 -0
- package/dist/cli/mcp.d.ts.map +1 -0
- package/dist/cli/mcp.js +60 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/navigation.d.ts +23 -0
- package/dist/cli/navigation.d.ts.map +1 -0
- package/dist/cli/navigation.js +367 -0
- package/dist/cli/navigation.js.map +1 -0
- package/dist/cli/options.d.ts +21 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +694 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/cli/orient.d.ts +6 -0
- package/dist/cli/orient.d.ts.map +1 -0
- package/dist/cli/orient.js +72 -0
- package/dist/cli/orient.js.map +1 -0
- package/dist/cli/packet.d.ts +4 -0
- package/dist/cli/packet.d.ts.map +1 -0
- package/dist/cli/packet.js +53 -0
- package/dist/cli/packet.js.map +1 -0
- package/dist/cli/pretty.d.ts +9 -0
- package/dist/cli/pretty.d.ts.map +1 -0
- package/dist/cli/pretty.js +91 -0
- package/dist/cli/pretty.js.map +1 -0
- package/dist/cli/progress.d.ts +20 -0
- package/dist/cli/progress.d.ts.map +1 -0
- package/dist/cli/progress.js +156 -0
- package/dist/cli/progress.js.map +1 -0
- package/dist/cli/projectFile.d.ts +13 -0
- package/dist/cli/projectFile.d.ts.map +1 -0
- package/dist/cli/projectFile.js +23 -0
- package/dist/cli/projectFile.js.map +1 -0
- package/dist/cli/refactorPlan.d.ts +6 -0
- package/dist/cli/refactorPlan.d.ts.map +1 -0
- package/dist/cli/refactorPlan.js +84 -0
- package/dist/cli/refactorPlan.js.map +1 -0
- package/dist/cli/renamePreview.d.ts +4 -0
- package/dist/cli/renamePreview.d.ts.map +1 -0
- package/dist/cli/renamePreview.js +86 -0
- package/dist/cli/renamePreview.js.map +1 -0
- package/dist/cli/review.d.ts +36 -0
- package/dist/cli/review.d.ts.map +1 -0
- package/dist/cli/review.js +302 -0
- package/dist/cli/review.js.map +1 -0
- package/dist/cli/rootPolicy.d.ts +53 -0
- package/dist/cli/rootPolicy.d.ts.map +1 -0
- package/dist/cli/rootPolicy.js +190 -0
- package/dist/cli/rootPolicy.js.map +1 -0
- package/dist/cli/search.d.ts +8 -0
- package/dist/cli/search.d.ts.map +1 -0
- package/dist/cli/search.js +49 -0
- package/dist/cli/search.js.map +1 -0
- package/dist/cli/skill.d.ts +13 -0
- package/dist/cli/skill.d.ts.map +1 -0
- package/dist/cli/skill.js +227 -0
- package/dist/cli/skill.js.map +1 -0
- package/dist/cli/sql.d.ts +6 -0
- package/dist/cli/sql.d.ts.map +1 -0
- package/dist/cli/sql.js +37 -0
- package/dist/cli/sql.js.map +1 -0
- package/dist/cli/symbols.d.ts +4 -0
- package/dist/cli/symbols.d.ts.map +1 -0
- package/dist/cli/symbols.js +59 -0
- package/dist/cli/symbols.js.map +1 -0
- package/dist/cli/typeHierarchy.d.ts +6 -0
- package/dist/cli/typeHierarchy.d.ts.map +1 -0
- package/dist/cli/typeHierarchy.js +81 -0
- package/dist/cli/typeHierarchy.js.map +1 -0
- package/dist/cli/viewer.d.ts +27 -0
- package/dist/cli/viewer.d.ts.map +1 -0
- package/dist/cli/viewer.js +313 -0
- package/dist/cli/viewer.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +185 -0
- package/dist/cli.js.map +1 -0
- package/dist/cliBootstrap.d.ts +3 -0
- package/dist/cliBootstrap.d.ts.map +1 -0
- package/dist/cliBootstrap.js +10 -0
- package/dist/cliBootstrap.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +141 -0
- package/dist/config.js.map +1 -0
- package/dist/documentLinks/asciidoc.d.ts +3 -0
- package/dist/documentLinks/asciidoc.d.ts.map +1 -0
- package/dist/documentLinks/asciidoc.js +115 -0
- package/dist/documentLinks/asciidoc.js.map +1 -0
- package/dist/documentLinks/check.d.ts +31 -0
- package/dist/documentLinks/check.d.ts.map +1 -0
- package/dist/documentLinks/check.js +272 -0
- package/dist/documentLinks/check.js.map +1 -0
- package/dist/documentLinks/html.d.ts +5 -0
- package/dist/documentLinks/html.d.ts.map +1 -0
- package/dist/documentLinks/html.js +324 -0
- package/dist/documentLinks/html.js.map +1 -0
- package/dist/documentLinks/markdown.d.ts +15 -0
- package/dist/documentLinks/markdown.d.ts.map +1 -0
- package/dist/documentLinks/markdown.js +538 -0
- package/dist/documentLinks/markdown.js.map +1 -0
- package/dist/documentLinks/rst.d.ts +3 -0
- package/dist/documentLinks/rst.d.ts.map +1 -0
- package/dist/documentLinks/rst.js +179 -0
- package/dist/documentLinks/rst.js.map +1 -0
- package/dist/documentLinks/sfc.d.ts +4 -0
- package/dist/documentLinks/sfc.d.ts.map +1 -0
- package/dist/documentLinks/sfc.js +30 -0
- package/dist/documentLinks/sfc.js.map +1 -0
- package/dist/documentLinks/shared.d.ts +11 -0
- package/dist/documentLinks/shared.d.ts.map +1 -0
- package/dist/documentLinks/shared.js +147 -0
- package/dist/documentLinks/shared.js.map +1 -0
- package/dist/documentLinks.d.ts +12 -0
- package/dist/documentLinks.d.ts.map +1 -0
- package/dist/documentLinks.js +50 -0
- package/dist/documentLinks.js.map +1 -0
- package/dist/drift/artifact.d.ts +3 -0
- package/dist/drift/artifact.d.ts.map +1 -0
- package/dist/drift/artifact.js +170 -0
- package/dist/drift/artifact.js.map +1 -0
- package/dist/drift/compare.d.ts +5 -0
- package/dist/drift/compare.d.ts.map +1 -0
- package/dist/drift/compare.js +355 -0
- package/dist/drift/compare.js.map +1 -0
- package/dist/drift/git.d.ts +3 -0
- package/dist/drift/git.d.ts.map +1 -0
- package/dist/drift/git.js +128 -0
- package/dist/drift/git.js.map +1 -0
- package/dist/drift/index.d.ts +8 -0
- package/dist/drift/index.d.ts.map +1 -0
- package/dist/drift/index.js +7 -0
- package/dist/drift/index.js.map +1 -0
- package/dist/drift/languages.d.ts +2 -0
- package/dist/drift/languages.d.ts.map +1 -0
- package/dist/drift/languages.js +18 -0
- package/dist/drift/languages.js.map +1 -0
- package/dist/drift/report.d.ts +6 -0
- package/dist/drift/report.d.ts.map +1 -0
- package/dist/drift/report.js +75 -0
- package/dist/drift/report.js.map +1 -0
- package/dist/drift/snapshot.d.ts +3 -0
- package/dist/drift/snapshot.d.ts.map +1 -0
- package/dist/drift/snapshot.js +164 -0
- package/dist/drift/snapshot.js.map +1 -0
- package/dist/drift/types.d.ts +142 -0
- package/dist/drift/types.d.ts.map +1 -0
- package/dist/drift/types.js +2 -0
- package/dist/drift/types.js.map +1 -0
- package/dist/duplicate-keywords.d.ts +3 -0
- package/dist/duplicate-keywords.d.ts.map +1 -0
- package/dist/duplicate-keywords.js +155 -0
- package/dist/duplicate-keywords.js.map +1 -0
- package/dist/duplicate-token-normalization.d.ts +6 -0
- package/dist/duplicate-token-normalization.d.ts.map +1 -0
- package/dist/duplicate-token-normalization.js +53 -0
- package/dist/duplicate-token-normalization.js.map +1 -0
- package/dist/duplicates/scoring.d.ts +121 -0
- package/dist/duplicates/scoring.d.ts.map +1 -0
- package/dist/duplicates/scoring.js +1245 -0
- package/dist/duplicates/scoring.js.map +1 -0
- package/dist/duplicates/types.d.ts +216 -0
- package/dist/duplicates/types.d.ts.map +1 -0
- package/dist/duplicates/types.js +2 -0
- package/dist/duplicates/types.js.map +1 -0
- package/dist/duplicates/unitCache.d.ts +40 -0
- package/dist/duplicates/unitCache.d.ts.map +1 -0
- package/dist/duplicates/unitCache.js +352 -0
- package/dist/duplicates/unitCache.js.map +1 -0
- package/dist/duplicates/units.d.ts +60 -0
- package/dist/duplicates/units.d.ts.map +1 -0
- package/dist/duplicates/units.js +447 -0
- package/dist/duplicates/units.js.map +1 -0
- package/dist/duplicates.d.ts +14 -0
- package/dist/duplicates.d.ts.map +1 -0
- package/dist/duplicates.js +400 -0
- package/dist/duplicates.js.map +1 -0
- package/dist/duplicatesLeads.d.ts +39 -0
- package/dist/duplicatesLeads.d.ts.map +1 -0
- package/dist/duplicatesLeads.js +112 -0
- package/dist/duplicatesLeads.js.map +1 -0
- package/dist/frameworks/angularjs.d.ts +18 -0
- package/dist/frameworks/angularjs.d.ts.map +1 -0
- package/dist/frameworks/angularjs.js +427 -0
- package/dist/frameworks/angularjs.js.map +1 -0
- package/dist/graph-builder.d.ts +35 -0
- package/dist/graph-builder.d.ts.map +1 -0
- package/dist/graph-builder.js +132 -0
- package/dist/graph-builder.js.map +1 -0
- package/dist/graph-edge-collector.d.ts +57 -0
- package/dist/graph-edge-collector.d.ts.map +1 -0
- package/dist/graph-edge-collector.js +199 -0
- package/dist/graph-edge-collector.js.map +1 -0
- package/dist/graphs/adjacency.d.ts +10 -0
- package/dist/graphs/adjacency.d.ts.map +1 -0
- package/dist/graphs/adjacency.js +38 -0
- package/dist/graphs/adjacency.js.map +1 -0
- package/dist/graphs/angularjs.d.ts +5 -0
- package/dist/graphs/angularjs.d.ts.map +1 -0
- package/dist/graphs/angularjs.js +88 -0
- package/dist/graphs/angularjs.js.map +1 -0
- package/dist/graphs/cycles.d.ts +24 -0
- package/dist/graphs/cycles.d.ts.map +1 -0
- package/dist/graphs/cycles.js +159 -0
- package/dist/graphs/cycles.js.map +1 -0
- package/dist/graphs/edgeResolution.d.ts +25 -0
- package/dist/graphs/edgeResolution.d.ts.map +1 -0
- package/dist/graphs/edgeResolution.js +97 -0
- package/dist/graphs/edgeResolution.js.map +1 -0
- package/dist/graphs/external/cache.d.ts +6 -0
- package/dist/graphs/external/cache.d.ts.map +1 -0
- package/dist/graphs/external/cache.js +21 -0
- package/dist/graphs/external/cache.js.map +1 -0
- package/dist/graphs/external/context.d.ts +9 -0
- package/dist/graphs/external/context.d.ts.map +1 -0
- package/dist/graphs/external/context.js +93 -0
- package/dist/graphs/external/context.js.map +1 -0
- package/dist/graphs/external/manifests.d.ts +8 -0
- package/dist/graphs/external/manifests.d.ts.map +1 -0
- package/dist/graphs/external/manifests.js +429 -0
- package/dist/graphs/external/manifests.js.map +1 -0
- package/dist/graphs/external/stdlib.d.ts +3 -0
- package/dist/graphs/external/stdlib.d.ts.map +1 -0
- package/dist/graphs/external/stdlib.js +166 -0
- package/dist/graphs/external/stdlib.js.map +1 -0
- package/dist/graphs/external-classifier.d.ts +16 -0
- package/dist/graphs/external-classifier.d.ts.map +1 -0
- package/dist/graphs/external-classifier.js +46 -0
- package/dist/graphs/external-classifier.js.map +1 -0
- package/dist/graphs/grep.d.ts +66 -0
- package/dist/graphs/grep.d.ts.map +1 -0
- package/dist/graphs/grep.js +131 -0
- package/dist/graphs/grep.js.map +1 -0
- package/dist/graphs/hotspots.d.ts +13 -0
- package/dist/graphs/hotspots.d.ts.map +1 -0
- package/dist/graphs/hotspots.js +88 -0
- package/dist/graphs/hotspots.js.map +1 -0
- package/dist/graphs/limits.d.ts +2 -0
- package/dist/graphs/limits.d.ts.map +1 -0
- package/dist/graphs/limits.js +7 -0
- package/dist/graphs/limits.js.map +1 -0
- package/dist/graphs/queries.d.ts +4 -0
- package/dist/graphs/queries.d.ts.map +1 -0
- package/dist/graphs/queries.js +4 -0
- package/dist/graphs/queries.js.map +1 -0
- package/dist/graphs/render.d.ts +6 -0
- package/dist/graphs/render.d.ts.map +1 -0
- package/dist/graphs/render.js +85 -0
- package/dist/graphs/render.js.map +1 -0
- package/dist/graphs/specifiers.d.ts +24 -0
- package/dist/graphs/specifiers.d.ts.map +1 -0
- package/dist/graphs/specifiers.js +434 -0
- package/dist/graphs/specifiers.js.map +1 -0
- package/dist/graphs/symbol-graph-detailed/ast.d.ts +25 -0
- package/dist/graphs/symbol-graph-detailed/ast.d.ts.map +1 -0
- package/dist/graphs/symbol-graph-detailed/ast.js +167 -0
- package/dist/graphs/symbol-graph-detailed/ast.js.map +1 -0
- package/dist/graphs/symbol-graph-detailed/edgePasses.d.ts +30 -0
- package/dist/graphs/symbol-graph-detailed/edgePasses.d.ts.map +1 -0
- package/dist/graphs/symbol-graph-detailed/edgePasses.js +484 -0
- package/dist/graphs/symbol-graph-detailed/edgePasses.js.map +1 -0
- package/dist/graphs/symbol-graph-detailed/importAliases.d.ts +10 -0
- package/dist/graphs/symbol-graph-detailed/importAliases.d.ts.map +1 -0
- package/dist/graphs/symbol-graph-detailed/importAliases.js +44 -0
- package/dist/graphs/symbol-graph-detailed/importAliases.js.map +1 -0
- package/dist/graphs/symbol-graph-detailed/memberChains.d.ts +17 -0
- package/dist/graphs/symbol-graph-detailed/memberChains.d.ts.map +1 -0
- package/dist/graphs/symbol-graph-detailed/memberChains.js +30 -0
- package/dist/graphs/symbol-graph-detailed/memberChains.js.map +1 -0
- package/dist/graphs/symbol-graph-detailed.d.ts +14 -0
- package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -0
- package/dist/graphs/symbol-graph-detailed.js +180 -0
- package/dist/graphs/symbol-graph-detailed.js.map +1 -0
- package/dist/graphs/symbol-graph.d.ts +56 -0
- package/dist/graphs/symbol-graph.d.ts.map +1 -0
- package/dist/graphs/symbol-graph.js +180 -0
- package/dist/graphs/symbol-graph.js.map +1 -0
- package/dist/graphs/symbol-render.d.ts +22 -0
- package/dist/graphs/symbol-render.d.ts.map +1 -0
- package/dist/graphs/symbol-render.js +184 -0
- package/dist/graphs/symbol-render.js.map +1 -0
- package/dist/graphs/traversal.d.ts +20 -0
- package/dist/graphs/traversal.d.ts.map +1 -0
- package/dist/graphs/traversal.js +75 -0
- package/dist/graphs/traversal.js.map +1 -0
- package/dist/graphs/types.d.ts +18 -0
- package/dist/graphs/types.d.ts.map +1 -0
- package/dist/graphs/types.js +2 -0
- package/dist/graphs/types.js.map +1 -0
- package/dist/graphs/unresolved.d.ts +13 -0
- package/dist/graphs/unresolved.d.ts.map +1 -0
- package/dist/graphs/unresolved.js +47 -0
- package/dist/graphs/unresolved.js.map +1 -0
- package/dist/graphs.d.ts +17 -0
- package/dist/graphs.d.ts.map +1 -0
- package/dist/graphs.js +11 -0
- package/dist/graphs.js.map +1 -0
- package/dist/impact/analyzer.d.ts +8 -0
- package/dist/impact/analyzer.d.ts.map +1 -0
- package/dist/impact/analyzer.js +156 -0
- package/dist/impact/analyzer.js.map +1 -0
- package/dist/impact/budgets.d.ts +36 -0
- package/dist/impact/budgets.d.ts.map +1 -0
- package/dist/impact/budgets.js +178 -0
- package/dist/impact/budgets.js.map +1 -0
- package/dist/impact/call-compatibility/providers/index.d.ts +14 -0
- package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -0
- package/dist/impact/call-compatibility/providers/index.js +58 -0
- package/dist/impact/call-compatibility/providers/index.js.map +1 -0
- package/dist/impact/call-compatibility/providers/types.d.ts +26 -0
- package/dist/impact/call-compatibility/providers/types.d.ts.map +1 -0
- package/dist/impact/call-compatibility/providers/types.js +2 -0
- package/dist/impact/call-compatibility/providers/types.js.map +1 -0
- package/dist/impact/call-compatibility/types.d.ts +24 -0
- package/dist/impact/call-compatibility/types.d.ts.map +1 -0
- package/dist/impact/call-compatibility/types.js +2 -0
- package/dist/impact/call-compatibility/types.js.map +1 -0
- package/dist/impact/callCompatibility.d.ts +17 -0
- package/dist/impact/callCompatibility.d.ts.map +1 -0
- package/dist/impact/callCompatibility.js +1546 -0
- package/dist/impact/callCompatibility.js.map +1 -0
- package/dist/impact/collect.d.ts +27 -0
- package/dist/impact/collect.d.ts.map +1 -0
- package/dist/impact/collect.js +97 -0
- package/dist/impact/collect.js.map +1 -0
- package/dist/impact/context.d.ts +42 -0
- package/dist/impact/context.d.ts.map +1 -0
- package/dist/impact/context.js +286 -0
- package/dist/impact/context.js.map +1 -0
- package/dist/impact/direct.d.ts +26 -0
- package/dist/impact/direct.d.ts.map +1 -0
- package/dist/impact/direct.js +187 -0
- package/dist/impact/direct.js.map +1 -0
- package/dist/impact/hunks.d.ts +14 -0
- package/dist/impact/hunks.d.ts.map +1 -0
- package/dist/impact/hunks.js +87 -0
- package/dist/impact/hunks.js.map +1 -0
- package/dist/impact/index.d.ts +22 -0
- package/dist/impact/index.d.ts.map +1 -0
- package/dist/impact/index.js +27 -0
- package/dist/impact/index.js.map +1 -0
- package/dist/impact/map.d.ts +12 -0
- package/dist/impact/map.d.ts.map +1 -0
- package/dist/impact/map.js +753 -0
- package/dist/impact/map.js.map +1 -0
- package/dist/impact/memberResolutionCoverage.d.ts +14 -0
- package/dist/impact/memberResolutionCoverage.d.ts.map +1 -0
- package/dist/impact/memberResolutionCoverage.js +38 -0
- package/dist/impact/memberResolutionCoverage.js.map +1 -0
- package/dist/impact/parse.d.ts +5 -0
- package/dist/impact/parse.d.ts.map +1 -0
- package/dist/impact/parse.js +239 -0
- package/dist/impact/parse.js.map +1 -0
- package/dist/impact/path.d.ts +14 -0
- package/dist/impact/path.d.ts.map +1 -0
- package/dist/impact/path.js +103 -0
- package/dist/impact/path.js.map +1 -0
- package/dist/impact/providers/base.d.ts +10 -0
- package/dist/impact/providers/base.d.ts.map +1 -0
- package/dist/impact/providers/base.js +239 -0
- package/dist/impact/providers/base.js.map +1 -0
- package/dist/impact/referenceCache.d.ts +12 -0
- package/dist/impact/referenceCache.d.ts.map +1 -0
- package/dist/impact/referenceCache.js +101 -0
- package/dist/impact/referenceCache.js.map +1 -0
- package/dist/impact/report-suggestions.d.ts +4 -0
- package/dist/impact/report-suggestions.d.ts.map +1 -0
- package/dist/impact/report-suggestions.js +886 -0
- package/dist/impact/report-suggestions.js.map +1 -0
- package/dist/impact/report.d.ts +8 -0
- package/dist/impact/report.d.ts.map +1 -0
- package/dist/impact/report.js +405 -0
- package/dist/impact/report.js.map +1 -0
- package/dist/impact/reportCompact.d.ts +8 -0
- package/dist/impact/reportCompact.d.ts.map +1 -0
- package/dist/impact/reportCompact.js +145 -0
- package/dist/impact/reportCompact.js.map +1 -0
- package/dist/impact/reportFull.d.ts +10 -0
- package/dist/impact/reportFull.d.ts.map +1 -0
- package/dist/impact/reportFull.js +66 -0
- package/dist/impact/reportFull.js.map +1 -0
- package/dist/impact/reportParts.d.ts +42 -0
- package/dist/impact/reportParts.d.ts.map +1 -0
- package/dist/impact/reportParts.js +2 -0
- package/dist/impact/reportParts.js.map +1 -0
- package/dist/impact/reportShared.d.ts +76 -0
- package/dist/impact/reportShared.d.ts.map +1 -0
- package/dist/impact/reportShared.js +130 -0
- package/dist/impact/reportShared.js.map +1 -0
- package/dist/impact/severity.d.ts +29 -0
- package/dist/impact/severity.d.ts.map +1 -0
- package/dist/impact/severity.js +178 -0
- package/dist/impact/severity.js.map +1 -0
- package/dist/impact/signature-node-utils.d.ts +5 -0
- package/dist/impact/signature-node-utils.d.ts.map +1 -0
- package/dist/impact/signature-node-utils.js +29 -0
- package/dist/impact/signature-node-utils.js.map +1 -0
- package/dist/impact/streaming.d.ts +60 -0
- package/dist/impact/streaming.d.ts.map +1 -0
- package/dist/impact/streaming.js +285 -0
- package/dist/impact/streaming.js.map +1 -0
- package/dist/impact/suggestions.d.ts +4 -0
- package/dist/impact/suggestions.d.ts.map +1 -0
- package/dist/impact/suggestions.js +317 -0
- package/dist/impact/suggestions.js.map +1 -0
- package/dist/impact/testPatterns.d.ts +6 -0
- package/dist/impact/testPatterns.d.ts.map +1 -0
- package/dist/impact/testPatterns.js +65 -0
- package/dist/impact/testPatterns.js.map +1 -0
- package/dist/impact/transitive.d.ts +12 -0
- package/dist/impact/transitive.d.ts.map +1 -0
- package/dist/impact/transitive.js +188 -0
- package/dist/impact/transitive.js.map +1 -0
- package/dist/impact/types.d.ts +556 -0
- package/dist/impact/types.d.ts.map +1 -0
- package/dist/impact/types.js +17 -0
- package/dist/impact/types.js.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/build-cache/manifest.d.ts +48 -0
- package/dist/indexer/build-cache/manifest.d.ts.map +1 -0
- package/dist/indexer/build-cache/manifest.js +228 -0
- package/dist/indexer/build-cache/manifest.js.map +1 -0
- package/dist/indexer/build-cache/module-cache.d.ts +20 -0
- package/dist/indexer/build-cache/module-cache.d.ts.map +1 -0
- package/dist/indexer/build-cache/module-cache.js +339 -0
- package/dist/indexer/build-cache/module-cache.js.map +1 -0
- package/dist/indexer/build-cache/options.d.ts +50 -0
- package/dist/indexer/build-cache/options.d.ts.map +1 -0
- package/dist/indexer/build-cache/options.js +276 -0
- package/dist/indexer/build-cache/options.js.map +1 -0
- package/dist/indexer/build-cache/project-snapshot.d.ts +30 -0
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -0
- package/dist/indexer/build-cache/project-snapshot.js +928 -0
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -0
- package/dist/indexer/build-cache/reports.d.ts +13 -0
- package/dist/indexer/build-cache/reports.d.ts.map +1 -0
- package/dist/indexer/build-cache/reports.js +134 -0
- package/dist/indexer/build-cache/reports.js.map +1 -0
- package/dist/indexer/build-cache.d.ts +6 -0
- package/dist/indexer/build-cache.d.ts.map +1 -0
- package/dist/indexer/build-cache.js +6 -0
- package/dist/indexer/build-cache.js.map +1 -0
- package/dist/indexer/build-index.d.ts +28 -0
- package/dist/indexer/build-index.d.ts.map +1 -0
- package/dist/indexer/build-index.js +1579 -0
- package/dist/indexer/build-index.js.map +1 -0
- package/dist/indexer/build-manifest.d.ts +16 -0
- package/dist/indexer/build-manifest.d.ts.map +1 -0
- package/dist/indexer/build-manifest.js +43 -0
- package/dist/indexer/build-manifest.js.map +1 -0
- package/dist/indexer/build-workers.d.ts +27 -0
- package/dist/indexer/build-workers.d.ts.map +1 -0
- package/dist/indexer/build-workers.js +209 -0
- package/dist/indexer/build-workers.js.map +1 -0
- package/dist/indexer/call-hierarchy.d.ts +33 -0
- package/dist/indexer/call-hierarchy.d.ts.map +1 -0
- package/dist/indexer/call-hierarchy.js +192 -0
- package/dist/indexer/call-hierarchy.js.map +1 -0
- package/dist/indexer/declarations.d.ts +15 -0
- package/dist/indexer/declarations.d.ts.map +1 -0
- package/dist/indexer/declarations.js +95 -0
- package/dist/indexer/declarations.js.map +1 -0
- package/dist/indexer/finalize.d.ts +20 -0
- package/dist/indexer/finalize.d.ts.map +1 -0
- package/dist/indexer/finalize.js +34 -0
- package/dist/indexer/finalize.js.map +1 -0
- package/dist/indexer/import-types.d.ts +48 -0
- package/dist/indexer/import-types.d.ts.map +1 -0
- package/dist/indexer/import-types.js +2 -0
- package/dist/indexer/import-types.js.map +1 -0
- package/dist/indexer/imports/context.d.ts +7 -0
- package/dist/indexer/imports/context.d.ts.map +1 -0
- package/dist/indexer/imports/context.js +2 -0
- package/dist/indexer/imports/context.js.map +1 -0
- package/dist/indexer/imports/graphOnly.d.ts +13 -0
- package/dist/indexer/imports/graphOnly.d.ts.map +1 -0
- package/dist/indexer/imports/graphOnly.js +40 -0
- package/dist/indexer/imports/graphOnly.js.map +1 -0
- package/dist/indexer/imports/jsTextImports.d.ts +9 -0
- package/dist/indexer/imports/jsTextImports.d.ts.map +1 -0
- package/dist/indexer/imports/jsTextImports.js +173 -0
- package/dist/indexer/imports/jsTextImports.js.map +1 -0
- package/dist/indexer/imports/languageSpecific.d.ts +26 -0
- package/dist/indexer/imports/languageSpecific.d.ts.map +1 -0
- package/dist/indexer/imports/languageSpecific.js +444 -0
- package/dist/indexer/imports/languageSpecific.js.map +1 -0
- package/dist/indexer/imports/nativeCaptures.d.ts +16 -0
- package/dist/indexer/imports/nativeCaptures.d.ts.map +1 -0
- package/dist/indexer/imports/nativeCaptures.js +139 -0
- package/dist/indexer/imports/nativeCaptures.js.map +1 -0
- package/dist/indexer/imports/python.d.ts +8 -0
- package/dist/indexer/imports/python.d.ts.map +1 -0
- package/dist/indexer/imports/python.js +116 -0
- package/dist/indexer/imports/python.js.map +1 -0
- package/dist/indexer/imports.d.ts +21 -0
- package/dist/indexer/imports.d.ts.map +1 -0
- package/dist/indexer/imports.js +188 -0
- package/dist/indexer/imports.js.map +1 -0
- package/dist/indexer/incremental-plan.d.ts +71 -0
- package/dist/indexer/incremental-plan.d.ts.map +1 -0
- package/dist/indexer/incremental-plan.js +212 -0
- package/dist/indexer/incremental-plan.js.map +1 -0
- package/dist/indexer/load-current-index.d.ts +51 -0
- package/dist/indexer/load-current-index.d.ts.map +1 -0
- package/dist/indexer/load-current-index.js +53 -0
- package/dist/indexer/load-current-index.js.map +1 -0
- package/dist/indexer/locals-and-exports.d.ts +12 -0
- package/dist/indexer/locals-and-exports.d.ts.map +1 -0
- package/dist/indexer/locals-and-exports.js +872 -0
- package/dist/indexer/locals-and-exports.js.map +1 -0
- package/dist/indexer/navigation-goto.d.ts +13 -0
- package/dist/indexer/navigation-goto.d.ts.map +1 -0
- package/dist/indexer/navigation-goto.js +548 -0
- package/dist/indexer/navigation-goto.js.map +1 -0
- package/dist/indexer/navigation-local.d.ts +13 -0
- package/dist/indexer/navigation-local.d.ts.map +1 -0
- package/dist/indexer/navigation-local.js +173 -0
- package/dist/indexer/navigation-local.js.map +1 -0
- package/dist/indexer/navigation-php.d.ts +7 -0
- package/dist/indexer/navigation-php.d.ts.map +1 -0
- package/dist/indexer/navigation-php.js +90 -0
- package/dist/indexer/navigation-php.js.map +1 -0
- package/dist/indexer/navigation-provenance.d.ts +14 -0
- package/dist/indexer/navigation-provenance.d.ts.map +1 -0
- package/dist/indexer/navigation-provenance.js +26 -0
- package/dist/indexer/navigation-provenance.js.map +1 -0
- package/dist/indexer/navigation-references.d.ts +30 -0
- package/dist/indexer/navigation-references.d.ts.map +1 -0
- package/dist/indexer/navigation-references.js +299 -0
- package/dist/indexer/navigation-references.js.map +1 -0
- package/dist/indexer/navigation-resolve.d.ts +12 -0
- package/dist/indexer/navigation-resolve.d.ts.map +1 -0
- package/dist/indexer/navigation-resolve.js +389 -0
- package/dist/indexer/navigation-resolve.js.map +1 -0
- package/dist/indexer/navigation.d.ts +19 -0
- package/dist/indexer/navigation.d.ts.map +1 -0
- package/dist/indexer/navigation.js +468 -0
- package/dist/indexer/navigation.js.map +1 -0
- package/dist/indexer/parse-context.d.ts +47 -0
- package/dist/indexer/parse-context.d.ts.map +1 -0
- package/dist/indexer/parse-context.js +127 -0
- package/dist/indexer/parse-context.js.map +1 -0
- package/dist/indexer/parsed-cache.d.ts +6 -0
- package/dist/indexer/parsed-cache.d.ts.map +1 -0
- package/dist/indexer/parsed-cache.js +32 -0
- package/dist/indexer/parsed-cache.js.map +1 -0
- package/dist/indexer/reference-candidate-types.d.ts +5 -0
- package/dist/indexer/reference-candidate-types.d.ts.map +1 -0
- package/dist/indexer/reference-candidate-types.js +2 -0
- package/dist/indexer/reference-candidate-types.js.map +1 -0
- package/dist/indexer/reference-candidates.d.ts +6 -0
- package/dist/indexer/reference-candidates.d.ts.map +1 -0
- package/dist/indexer/reference-candidates.js +28 -0
- package/dist/indexer/reference-candidates.js.map +1 -0
- package/dist/indexer/reference-context.d.ts +13 -0
- package/dist/indexer/reference-context.d.ts.map +1 -0
- package/dist/indexer/reference-context.js +103 -0
- package/dist/indexer/reference-context.js.map +1 -0
- package/dist/indexer/scope-types.d.ts +25 -0
- package/dist/indexer/scope-types.d.ts.map +1 -0
- package/dist/indexer/scope-types.js +2 -0
- package/dist/indexer/scope-types.js.map +1 -0
- package/dist/indexer/scope.d.ts +11 -0
- package/dist/indexer/scope.d.ts.map +1 -0
- package/dist/indexer/scope.js +424 -0
- package/dist/indexer/scope.js.map +1 -0
- package/dist/indexer/shared.d.ts +4 -0
- package/dist/indexer/shared.d.ts.map +1 -0
- package/dist/indexer/shared.js +9 -0
- package/dist/indexer/shared.js.map +1 -0
- package/dist/indexer/symbols.d.ts +60 -0
- package/dist/indexer/symbols.d.ts.map +1 -0
- package/dist/indexer/symbols.js +272 -0
- package/dist/indexer/symbols.js.map +1 -0
- package/dist/indexer/type-hierarchy.d.ts +52 -0
- package/dist/indexer/type-hierarchy.d.ts.map +1 -0
- package/dist/indexer/type-hierarchy.js +296 -0
- package/dist/indexer/type-hierarchy.js.map +1 -0
- package/dist/indexer/types.d.ts +376 -0
- package/dist/indexer/types.d.ts.map +1 -0
- package/dist/indexer/types.js +15 -0
- package/dist/indexer/types.js.map +1 -0
- package/dist/indexer/workspace-symbols.d.ts +35 -0
- package/dist/indexer/workspace-symbols.d.ts.map +1 -0
- package/dist/indexer/workspace-symbols.js +226 -0
- package/dist/indexer/workspace-symbols.js.map +1 -0
- package/dist/indexer.d.ts +44 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +35 -0
- package/dist/indexer.js.map +1 -0
- package/dist/installer/registry.d.ts +68 -0
- package/dist/installer/registry.d.ts.map +1 -0
- package/dist/installer/registry.js +1208 -0
- package/dist/installer/registry.js.map +1 -0
- package/dist/languages/all.d.ts +28 -0
- package/dist/languages/all.d.ts.map +1 -0
- package/dist/languages/all.js +28 -0
- package/dist/languages/all.js.map +1 -0
- package/dist/languages/definitions/adoc.d.ts +2 -0
- package/dist/languages/definitions/adoc.d.ts.map +1 -0
- package/dist/languages/definitions/adoc.js +5 -0
- package/dist/languages/definitions/adoc.js.map +1 -0
- package/dist/languages/definitions/astro.d.ts +2 -0
- package/dist/languages/definitions/astro.d.ts.map +1 -0
- package/dist/languages/definitions/astro.js +5 -0
- package/dist/languages/definitions/astro.js.map +1 -0
- package/dist/languages/definitions/c.d.ts +2 -0
- package/dist/languages/definitions/c.d.ts.map +1 -0
- package/dist/languages/definitions/c.js +78 -0
- package/dist/languages/definitions/c.js.map +1 -0
- package/dist/languages/definitions/cFamily.d.ts +35 -0
- package/dist/languages/definitions/cFamily.d.ts.map +1 -0
- package/dist/languages/definitions/cFamily.js +179 -0
- package/dist/languages/definitions/cFamily.js.map +1 -0
- package/dist/languages/definitions/cpp.d.ts +2 -0
- package/dist/languages/definitions/cpp.d.ts.map +1 -0
- package/dist/languages/definitions/cpp.js +88 -0
- package/dist/languages/definitions/cpp.js.map +1 -0
- package/dist/languages/definitions/csharp.d.ts +3 -0
- package/dist/languages/definitions/csharp.d.ts.map +1 -0
- package/dist/languages/definitions/csharp.js +126 -0
- package/dist/languages/definitions/csharp.js.map +1 -0
- package/dist/languages/definitions/css.d.ts +3 -0
- package/dist/languages/definitions/css.d.ts.map +1 -0
- package/dist/languages/definitions/css.js +13 -0
- package/dist/languages/definitions/css.js.map +1 -0
- package/dist/languages/definitions/cssLike.d.ts +5 -0
- package/dist/languages/definitions/cssLike.d.ts.map +1 -0
- package/dist/languages/definitions/cssLike.js +32 -0
- package/dist/languages/definitions/cssLike.js.map +1 -0
- package/dist/languages/definitions/go.d.ts +3 -0
- package/dist/languages/definitions/go.d.ts.map +1 -0
- package/dist/languages/definitions/go.js +113 -0
- package/dist/languages/definitions/go.js.map +1 -0
- package/dist/languages/definitions/hbs.d.ts +2 -0
- package/dist/languages/definitions/hbs.d.ts.map +1 -0
- package/dist/languages/definitions/hbs.js +5 -0
- package/dist/languages/definitions/hbs.js.map +1 -0
- package/dist/languages/definitions/html.d.ts +3 -0
- package/dist/languages/definitions/html.d.ts.map +1 -0
- package/dist/languages/definitions/html.js +45 -0
- package/dist/languages/definitions/html.js.map +1 -0
- package/dist/languages/definitions/htmlStub.d.ts +18 -0
- package/dist/languages/definitions/htmlStub.d.ts.map +1 -0
- package/dist/languages/definitions/htmlStub.js +38 -0
- package/dist/languages/definitions/htmlStub.js.map +1 -0
- package/dist/languages/definitions/java.d.ts +3 -0
- package/dist/languages/definitions/java.d.ts.map +1 -0
- package/dist/languages/definitions/java.js +124 -0
- package/dist/languages/definitions/java.js.map +1 -0
- package/dist/languages/definitions/javascript.d.ts +3 -0
- package/dist/languages/definitions/javascript.d.ts.map +1 -0
- package/dist/languages/definitions/javascript.js +172 -0
- package/dist/languages/definitions/javascript.js.map +1 -0
- package/dist/languages/definitions/jsFamily.d.ts +5 -0
- package/dist/languages/definitions/jsFamily.d.ts.map +1 -0
- package/dist/languages/definitions/jsFamily.js +75 -0
- package/dist/languages/definitions/jsFamily.js.map +1 -0
- package/dist/languages/definitions/kotlin.d.ts +3 -0
- package/dist/languages/definitions/kotlin.d.ts.map +1 -0
- package/dist/languages/definitions/kotlin.js +152 -0
- package/dist/languages/definitions/kotlin.js.map +1 -0
- package/dist/languages/definitions/less.d.ts +3 -0
- package/dist/languages/definitions/less.d.ts.map +1 -0
- package/dist/languages/definitions/less.js +13 -0
- package/dist/languages/definitions/less.js.map +1 -0
- package/dist/languages/definitions/loadLanguage.d.ts +2 -0
- package/dist/languages/definitions/loadLanguage.d.ts.map +1 -0
- package/dist/languages/definitions/loadLanguage.js +2 -0
- package/dist/languages/definitions/loadLanguage.js.map +1 -0
- package/dist/languages/definitions/markdown.d.ts +2 -0
- package/dist/languages/definitions/markdown.d.ts.map +1 -0
- package/dist/languages/definitions/markdown.js +5 -0
- package/dist/languages/definitions/markdown.js.map +1 -0
- package/dist/languages/definitions/mdx.d.ts +2 -0
- package/dist/languages/definitions/mdx.d.ts.map +1 -0
- package/dist/languages/definitions/mdx.js +5 -0
- package/dist/languages/definitions/mdx.js.map +1 -0
- package/dist/languages/definitions/php.d.ts +3 -0
- package/dist/languages/definitions/php.d.ts.map +1 -0
- package/dist/languages/definitions/php.js +157 -0
- package/dist/languages/definitions/php.js.map +1 -0
- package/dist/languages/definitions/python.d.ts +3 -0
- package/dist/languages/definitions/python.d.ts.map +1 -0
- package/dist/languages/definitions/python.js +137 -0
- package/dist/languages/definitions/python.js.map +1 -0
- package/dist/languages/definitions/rst.d.ts +2 -0
- package/dist/languages/definitions/rst.d.ts.map +1 -0
- package/dist/languages/definitions/rst.js +5 -0
- package/dist/languages/definitions/rst.js.map +1 -0
- package/dist/languages/definitions/ruby.d.ts +3 -0
- package/dist/languages/definitions/ruby.d.ts.map +1 -0
- package/dist/languages/definitions/ruby.js +92 -0
- package/dist/languages/definitions/ruby.js.map +1 -0
- package/dist/languages/definitions/rust.d.ts +3 -0
- package/dist/languages/definitions/rust.d.ts.map +1 -0
- package/dist/languages/definitions/rust.js +146 -0
- package/dist/languages/definitions/rust.js.map +1 -0
- package/dist/languages/definitions/scss.d.ts +3 -0
- package/dist/languages/definitions/scss.d.ts.map +1 -0
- package/dist/languages/definitions/scss.js +58 -0
- package/dist/languages/definitions/scss.js.map +1 -0
- package/dist/languages/definitions/sql.d.ts +3 -0
- package/dist/languages/definitions/sql.d.ts.map +1 -0
- package/dist/languages/definitions/sql.js +36 -0
- package/dist/languages/definitions/sql.js.map +1 -0
- package/dist/languages/definitions/svelte.d.ts +3 -0
- package/dist/languages/definitions/svelte.d.ts.map +1 -0
- package/dist/languages/definitions/svelte.js +31 -0
- package/dist/languages/definitions/svelte.js.map +1 -0
- package/dist/languages/definitions/swift.d.ts +3 -0
- package/dist/languages/definitions/swift.d.ts.map +1 -0
- package/dist/languages/definitions/swift.js +188 -0
- package/dist/languages/definitions/swift.js.map +1 -0
- package/dist/languages/definitions/typescript.d.ts +4 -0
- package/dist/languages/definitions/typescript.d.ts.map +1 -0
- package/dist/languages/definitions/typescript.js +212 -0
- package/dist/languages/definitions/typescript.js.map +1 -0
- package/dist/languages/definitions/vue.d.ts +3 -0
- package/dist/languages/definitions/vue.d.ts.map +1 -0
- package/dist/languages/definitions/vue.js +31 -0
- package/dist/languages/definitions/vue.js.map +1 -0
- package/dist/languages/definitions/zig.d.ts +3 -0
- package/dist/languages/definitions/zig.d.ts.map +1 -0
- package/dist/languages/definitions/zig.js +75 -0
- package/dist/languages/definitions/zig.js.map +1 -0
- package/dist/languages/filePrep.d.ts +33 -0
- package/dist/languages/filePrep.d.ts.map +1 -0
- package/dist/languages/filePrep.js +77 -0
- package/dist/languages/filePrep.js.map +1 -0
- package/dist/languages/importStatementParsers.d.ts +55 -0
- package/dist/languages/importStatementParsers.d.ts.map +1 -0
- package/dist/languages/importStatementParsers.js +369 -0
- package/dist/languages/importStatementParsers.js.map +1 -0
- package/dist/languages/js-family.d.ts +2 -0
- package/dist/languages/js-family.d.ts.map +1 -0
- package/dist/languages/js-family.js +9 -0
- package/dist/languages/js-family.js.map +1 -0
- package/dist/languages/queryGenerator.d.ts +6 -0
- package/dist/languages/queryGenerator.d.ts.map +1 -0
- package/dist/languages/queryGenerator.js +46 -0
- package/dist/languages/queryGenerator.js.map +1 -0
- package/dist/languages/registry.d.ts +5 -0
- package/dist/languages/registry.d.ts.map +1 -0
- package/dist/languages/registry.js +11 -0
- package/dist/languages/registry.js.map +1 -0
- package/dist/languages/sfc.d.ts +30 -0
- package/dist/languages/sfc.d.ts.map +1 -0
- package/dist/languages/sfc.js +402 -0
- package/dist/languages/sfc.js.map +1 -0
- package/dist/languages/types.d.ts +110 -0
- package/dist/languages/types.d.ts.map +1 -0
- package/dist/languages/types.js +2 -0
- package/dist/languages/types.js.map +1 -0
- package/dist/languages.d.ts +63 -0
- package/dist/languages.d.ts.map +1 -0
- package/dist/languages.js +118 -0
- package/dist/languages.js.map +1 -0
- package/dist/lifecycle/errors.d.ts +4 -0
- package/dist/lifecycle/errors.d.ts.map +1 -0
- package/dist/lifecycle/errors.js +4 -0
- package/dist/lifecycle/errors.js.map +1 -0
- package/dist/lifecycle/gitignore.d.ts +10 -0
- package/dist/lifecycle/gitignore.d.ts.map +1 -0
- package/dist/lifecycle/gitignore.js +83 -0
- package/dist/lifecycle/gitignore.js.map +1 -0
- package/dist/lifecycle/manifest.d.ts +73 -0
- package/dist/lifecycle/manifest.d.ts.map +1 -0
- package/dist/lifecycle/manifest.js +352 -0
- package/dist/lifecycle/manifest.js.map +1 -0
- package/dist/logging.d.ts +5 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +35 -0
- package/dist/logging.js.map +1 -0
- package/dist/mcp/http.d.ts +29 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/http.js +179 -0
- package/dist/mcp/http.js.map +1 -0
- package/dist/mcp/security.d.ts +3 -0
- package/dist/mcp/security.d.ts.map +1 -0
- package/dist/mcp/security.js +23 -0
- package/dist/mcp/security.js.map +1 -0
- package/dist/mcp/server.d.ts +267 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +1345 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/sqliteGuard.d.ts +3 -0
- package/dist/mcp/sqliteGuard.d.ts.map +1 -0
- package/dist/mcp/sqliteGuard.js +35 -0
- package/dist/mcp/sqliteGuard.js.map +1 -0
- package/dist/mcp/stdioLifecycle.d.ts +23 -0
- package/dist/mcp/stdioLifecycle.d.ts.map +1 -0
- package/dist/mcp/stdioLifecycle.js +83 -0
- package/dist/mcp/stdioLifecycle.js.map +1 -0
- package/dist/mcp/tools.d.ts +15 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +299 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp.d.ts +9 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +8 -0
- package/dist/mcp.js.map +1 -0
- package/dist/native/bindingLoader.d.ts +24 -0
- package/dist/native/bindingLoader.d.ts.map +1 -0
- package/dist/native/bindingLoader.js +206 -0
- package/dist/native/bindingLoader.js.map +1 -0
- package/dist/native/contracts.d.ts +122 -0
- package/dist/native/contracts.d.ts.map +1 -0
- package/dist/native/contracts.js +2 -0
- package/dist/native/contracts.js.map +1 -0
- package/dist/native/execution.d.ts +16 -0
- package/dist/native/execution.d.ts.map +1 -0
- package/dist/native/execution.js +184 -0
- package/dist/native/execution.js.map +1 -0
- package/dist/native/jsBridge.d.ts +7 -0
- package/dist/native/jsBridge.d.ts.map +1 -0
- package/dist/native/jsBridge.js +25 -0
- package/dist/native/jsBridge.js.map +1 -0
- package/dist/native/nativeBackendReport.d.ts +22 -0
- package/dist/native/nativeBackendReport.d.ts.map +1 -0
- package/dist/native/nativeBackendReport.js +102 -0
- package/dist/native/nativeBackendReport.js.map +1 -0
- package/dist/native/projectedTree.d.ts +37 -0
- package/dist/native/projectedTree.d.ts.map +1 -0
- package/dist/native/projectedTree.js +172 -0
- package/dist/native/projectedTree.js.map +1 -0
- package/dist/native/queries.d.ts +22 -0
- package/dist/native/queries.d.ts.map +1 -0
- package/dist/native/queries.js +67 -0
- package/dist/native/queries.js.map +1 -0
- package/dist/native/queryResults.d.ts +6 -0
- package/dist/native/queryResults.d.ts.map +1 -0
- package/dist/native/queryResults.js +26 -0
- package/dist/native/queryResults.js.map +1 -0
- package/dist/native/runtime.d.ts +17 -0
- package/dist/native/runtime.d.ts.map +1 -0
- package/dist/native/runtime.js +152 -0
- package/dist/native/runtime.js.map +1 -0
- package/dist/native/runtimeCache.d.ts +36 -0
- package/dist/native/runtimeCache.d.ts.map +1 -0
- package/dist/native/runtimeCache.js +237 -0
- package/dist/native/runtimeCache.js.map +1 -0
- package/dist/native/treeSitterNative.d.ts +6 -0
- package/dist/native/treeSitterNative.d.ts.map +1 -0
- package/dist/native/treeSitterNative.js +5 -0
- package/dist/native/treeSitterNative.js.map +1 -0
- package/dist/parserBackend.d.ts +57 -0
- package/dist/parserBackend.d.ts.map +1 -0
- package/dist/parserBackend.js +33 -0
- package/dist/parserBackend.js.map +1 -0
- package/dist/presentation/bounds.d.ts +34 -0
- package/dist/presentation/bounds.d.ts.map +1 -0
- package/dist/presentation/bounds.js +43 -0
- package/dist/presentation/bounds.js.map +1 -0
- package/dist/presets.d.ts +32 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +127 -0
- package/dist/presets.js.map +1 -0
- package/dist/query/parser.d.ts +33 -0
- package/dist/query/parser.d.ts.map +1 -0
- package/dist/query/parser.js +104 -0
- package/dist/query/parser.js.map +1 -0
- package/dist/query/symbols.d.ts +15 -0
- package/dist/query/symbols.d.ts.map +1 -0
- package/dist/query/symbols.js +78 -0
- package/dist/query/symbols.js.map +1 -0
- package/dist/query.d.ts +3 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +3 -0
- package/dist/query.js.map +1 -0
- package/dist/review/candidates.d.ts +13 -0
- package/dist/review/candidates.d.ts.map +1 -0
- package/dist/review/candidates.js +65 -0
- package/dist/review/candidates.js.map +1 -0
- package/dist/review/changes.d.ts +11 -0
- package/dist/review/changes.d.ts.map +1 -0
- package/dist/review/changes.js +94 -0
- package/dist/review/changes.js.map +1 -0
- package/dist/review/deleted.d.ts +23 -0
- package/dist/review/deleted.d.ts.map +1 -0
- package/dist/review/deleted.js +398 -0
- package/dist/review/deleted.js.map +1 -0
- package/dist/review/report.d.ts +37 -0
- package/dist/review/report.d.ts.map +1 -0
- package/dist/review/report.js +76 -0
- package/dist/review/report.js.map +1 -0
- package/dist/review/risk.d.ts +19 -0
- package/dist/review/risk.d.ts.map +1 -0
- package/dist/review/risk.js +105 -0
- package/dist/review/risk.js.map +1 -0
- package/dist/review/summaries.d.ts +24 -0
- package/dist/review/summaries.d.ts.map +1 -0
- package/dist/review/summaries.js +581 -0
- package/dist/review/summaries.js.map +1 -0
- package/dist/review/types.d.ts +146 -0
- package/dist/review/types.d.ts.map +1 -0
- package/dist/review/types.js +43 -0
- package/dist/review/types.js.map +1 -0
- package/dist/review.d.ts +19 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +442 -0
- package/dist/review.js.map +1 -0
- package/dist/runtimeIdentity.d.ts +27 -0
- package/dist/runtimeIdentity.d.ts.map +1 -0
- package/dist/runtimeIdentity.js +75 -0
- package/dist/runtimeIdentity.js.map +1 -0
- package/dist/session.d.ts +246 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +858 -0
- package/dist/session.js.map +1 -0
- package/dist/sql/classifySqlFile.d.ts +3 -0
- package/dist/sql/classifySqlFile.d.ts.map +1 -0
- package/dist/sql/classifySqlFile.js +42 -0
- package/dist/sql/classifySqlFile.js.map +1 -0
- package/dist/sql/extractFacts.d.ts +4 -0
- package/dist/sql/extractFacts.d.ts.map +1 -0
- package/dist/sql/extractFacts.js +511 -0
- package/dist/sql/extractFacts.js.map +1 -0
- package/dist/sql/graph.d.ts +33 -0
- package/dist/sql/graph.d.ts.map +1 -0
- package/dist/sql/graph.js +167 -0
- package/dist/sql/graph.js.map +1 -0
- package/dist/sql/index.d.ts +8 -0
- package/dist/sql/index.d.ts.map +1 -0
- package/dist/sql/index.js +5 -0
- package/dist/sql/index.js.map +1 -0
- package/dist/sql/lex.d.ts +12 -0
- package/dist/sql/lex.d.ts.map +1 -0
- package/dist/sql/lex.js +180 -0
- package/dist/sql/lex.js.map +1 -0
- package/dist/sql/lookup.d.ts +3 -0
- package/dist/sql/lookup.d.ts.map +1 -0
- package/dist/sql/lookup.js +11 -0
- package/dist/sql/lookup.js.map +1 -0
- package/dist/sql/navigation.d.ts +4 -0
- package/dist/sql/navigation.d.ts.map +1 -0
- package/dist/sql/navigation.js +399 -0
- package/dist/sql/navigation.js.map +1 -0
- package/dist/sql/review.d.ts +15 -0
- package/dist/sql/review.d.ts.map +1 -0
- package/dist/sql/review.js +197 -0
- package/dist/sql/review.js.map +1 -0
- package/dist/sql/sourceGraph.d.ts +19 -0
- package/dist/sql/sourceGraph.d.ts.map +1 -0
- package/dist/sql/sourceGraph.js +195 -0
- package/dist/sql/sourceGraph.js.map +1 -0
- package/dist/sql/types.d.ts +21 -0
- package/dist/sql/types.d.ts.map +1 -0
- package/dist/sql/types.js +2 -0
- package/dist/sql/types.js.map +1 -0
- package/dist/sqlite/canned-query.d.ts +3 -0
- package/dist/sqlite/canned-query.d.ts.map +1 -0
- package/dist/sqlite/canned-query.js +192 -0
- package/dist/sqlite/canned-query.js.map +1 -0
- package/dist/sqlite/common.d.ts +6 -0
- package/dist/sqlite/common.d.ts.map +1 -0
- package/dist/sqlite/common.js +42 -0
- package/dist/sqlite/common.js.map +1 -0
- package/dist/sqlite/database.d.ts +5 -0
- package/dist/sqlite/database.d.ts.map +1 -0
- package/dist/sqlite/database.js +40 -0
- package/dist/sqlite/database.js.map +1 -0
- package/dist/sqlite/query.d.ts +9 -0
- package/dist/sqlite/query.d.ts.map +1 -0
- package/dist/sqlite/query.js +32 -0
- package/dist/sqlite/query.js.map +1 -0
- package/dist/sqlite/rowBounds.d.ts +24 -0
- package/dist/sqlite/rowBounds.d.ts.map +1 -0
- package/dist/sqlite/rowBounds.js +95 -0
- package/dist/sqlite/rowBounds.js.map +1 -0
- package/dist/sqlite/schema.d.ts +5 -0
- package/dist/sqlite/schema.d.ts.map +1 -0
- package/dist/sqlite/schema.js +243 -0
- package/dist/sqlite/schema.js.map +1 -0
- package/dist/sqlite/types.d.ts +77 -0
- package/dist/sqlite/types.d.ts.map +1 -0
- package/dist/sqlite/types.js +2 -0
- package/dist/sqlite/types.js.map +1 -0
- package/dist/sqlite/write.d.ts +5 -0
- package/dist/sqlite/write.d.ts.map +1 -0
- package/dist/sqlite/write.js +306 -0
- package/dist/sqlite/write.js.map +1 -0
- package/dist/sqlite-driver.d.ts +41 -0
- package/dist/sqlite-driver.d.ts.map +1 -0
- package/dist/sqlite-driver.js +144 -0
- package/dist/sqlite-driver.js.map +1 -0
- package/dist/sqlite.d.ts +4 -0
- package/dist/sqlite.d.ts.map +1 -0
- package/dist/sqlite.js +3 -0
- package/dist/sqlite.js.map +1 -0
- package/dist/triples.d.ts +27 -0
- package/dist/triples.d.ts.map +1 -0
- package/dist/triples.js +46 -0
- package/dist/triples.js.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util/ast.d.ts +20 -0
- package/dist/util/ast.d.ts.map +1 -0
- package/dist/util/ast.js +62 -0
- package/dist/util/ast.js.map +1 -0
- package/dist/util/bloomFilter.d.ts +99 -0
- package/dist/util/bloomFilter.d.ts.map +1 -0
- package/dist/util/bloomFilter.js +205 -0
- package/dist/util/bloomFilter.js.map +1 -0
- package/dist/util/collections.d.ts +3 -0
- package/dist/util/collections.d.ts.map +1 -0
- package/dist/util/collections.js +21 -0
- package/dist/util/collections.js.map +1 -0
- package/dist/util/comments.d.ts +10 -0
- package/dist/util/comments.d.ts.map +1 -0
- package/dist/util/comments.js +398 -0
- package/dist/util/comments.js.map +1 -0
- package/dist/util/concurrency.d.ts +26 -0
- package/dist/util/concurrency.d.ts.map +1 -0
- package/dist/util/concurrency.js +121 -0
- package/dist/util/concurrency.js.map +1 -0
- package/dist/util/confinedFile.d.ts +8 -0
- package/dist/util/confinedFile.d.ts.map +1 -0
- package/dist/util/confinedFile.js +53 -0
- package/dist/util/confinedFile.js.map +1 -0
- package/dist/util/discoveryPath.d.ts +3 -0
- package/dist/util/discoveryPath.d.ts.map +1 -0
- package/dist/util/discoveryPath.js +19 -0
- package/dist/util/discoveryPath.js.map +1 -0
- package/dist/util/errors.d.ts +3 -0
- package/dist/util/errors.d.ts.map +1 -0
- package/dist/util/errors.js +7 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/git.d.ts +79 -0
- package/dist/util/git.d.ts.map +1 -0
- package/dist/util/git.js +403 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/graphEdges.d.ts +5 -0
- package/dist/util/graphEdges.d.ts.map +1 -0
- package/dist/util/graphEdges.js +42 -0
- package/dist/util/graphEdges.js.map +1 -0
- package/dist/util/graphOnlyExtensions.d.ts +5 -0
- package/dist/util/graphOnlyExtensions.d.ts.map +1 -0
- package/dist/util/graphOnlyExtensions.js +12 -0
- package/dist/util/graphOnlyExtensions.js.map +1 -0
- package/dist/util/guards.d.ts +2 -0
- package/dist/util/guards.d.ts.map +1 -0
- package/dist/util/guards.js +4 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/includeRoots.d.ts +6 -0
- package/dist/util/includeRoots.d.ts.map +1 -0
- package/dist/util/includeRoots.js +53 -0
- package/dist/util/includeRoots.js.map +1 -0
- package/dist/util/lazySymbols.d.ts +166 -0
- package/dist/util/lazySymbols.d.ts.map +1 -0
- package/dist/util/lazySymbols.js +365 -0
- package/dist/util/lazySymbols.js.map +1 -0
- package/dist/util/lines.d.ts +2 -0
- package/dist/util/lines.d.ts.map +1 -0
- package/dist/util/lines.js +9 -0
- package/dist/util/lines.js.map +1 -0
- package/dist/util/lruMap.d.ts +3 -0
- package/dist/util/lruMap.d.ts.map +1 -0
- package/dist/util/lruMap.js +22 -0
- package/dist/util/lruMap.js.map +1 -0
- package/dist/util/memberAccess.d.ts +26 -0
- package/dist/util/memberAccess.d.ts.map +1 -0
- package/dist/util/memberAccess.js +175 -0
- package/dist/util/memberAccess.js.map +1 -0
- package/dist/util/packageExports.d.ts +25 -0
- package/dist/util/packageExports.d.ts.map +1 -0
- package/dist/util/packageExports.js +79 -0
- package/dist/util/packageExports.js.map +1 -0
- package/dist/util/packageInfo.d.ts +12 -0
- package/dist/util/packageInfo.d.ts.map +1 -0
- package/dist/util/packageInfo.js +57 -0
- package/dist/util/packageInfo.js.map +1 -0
- package/dist/util/partialResults.d.ts +81 -0
- package/dist/util/partialResults.d.ts.map +1 -0
- package/dist/util/partialResults.js +290 -0
- package/dist/util/partialResults.js.map +1 -0
- package/dist/util/paths.d.ts +51 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +245 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/projectFiles/definitions.d.ts +21 -0
- package/dist/util/projectFiles/definitions.d.ts.map +1 -0
- package/dist/util/projectFiles/definitions.js +112 -0
- package/dist/util/projectFiles/definitions.js.map +1 -0
- package/dist/util/projectFiles/parsers.d.ts +13 -0
- package/dist/util/projectFiles/parsers.d.ts.map +1 -0
- package/dist/util/projectFiles/parsers.js +122 -0
- package/dist/util/projectFiles/parsers.js.map +1 -0
- package/dist/util/projectFiles.d.ts +43 -0
- package/dist/util/projectFiles.d.ts.map +1 -0
- package/dist/util/projectFiles.js +572 -0
- package/dist/util/projectFiles.js.map +1 -0
- package/dist/util/resolution/files.d.ts +3 -0
- package/dist/util/resolution/files.d.ts.map +1 -0
- package/dist/util/resolution/files.js +29 -0
- package/dist/util/resolution/files.js.map +1 -0
- package/dist/util/resolution/findFirstExisting.d.ts +2 -0
- package/dist/util/resolution/findFirstExisting.d.ts.map +1 -0
- package/dist/util/resolution/findFirstExisting.js +13 -0
- package/dist/util/resolution/findFirstExisting.js.map +1 -0
- package/dist/util/resolution/go.d.ts +2 -0
- package/dist/util/resolution/go.d.ts.map +1 -0
- package/dist/util/resolution/go.js +171 -0
- package/dist/util/resolution/go.js.map +1 -0
- package/dist/util/resolution/jvm.d.ts +5 -0
- package/dist/util/resolution/jvm.d.ts.map +1 -0
- package/dist/util/resolution/jvm.js +124 -0
- package/dist/util/resolution/jvm.js.map +1 -0
- package/dist/util/resolution/node.d.ts +3 -0
- package/dist/util/resolution/node.d.ts.map +1 -0
- package/dist/util/resolution/node.js +60 -0
- package/dist/util/resolution/node.js.map +1 -0
- package/dist/util/resolution/php.d.ts +4 -0
- package/dist/util/resolution/php.d.ts.map +1 -0
- package/dist/util/resolution/php.js +498 -0
- package/dist/util/resolution/php.js.map +1 -0
- package/dist/util/resolution/phpComposer.d.ts +17 -0
- package/dist/util/resolution/phpComposer.d.ts.map +1 -0
- package/dist/util/resolution/phpComposer.js +269 -0
- package/dist/util/resolution/phpComposer.js.map +1 -0
- package/dist/util/resolution/projectSymbols.d.ts +14 -0
- package/dist/util/resolution/projectSymbols.d.ts.map +1 -0
- package/dist/util/resolution/projectSymbols.js +70 -0
- package/dist/util/resolution/projectSymbols.js.map +1 -0
- package/dist/util/resolution/python.d.ts +7 -0
- package/dist/util/resolution/python.d.ts.map +1 -0
- package/dist/util/resolution/python.js +129 -0
- package/dist/util/resolution/python.js.map +1 -0
- package/dist/util/resolution/rust.d.ts +2 -0
- package/dist/util/resolution/rust.d.ts.map +1 -0
- package/dist/util/resolution/rust.js +87 -0
- package/dist/util/resolution/rust.js.map +1 -0
- package/dist/util/resolution/tsconfig.d.ts +8 -0
- package/dist/util/resolution/tsconfig.d.ts.map +1 -0
- package/dist/util/resolution/tsconfig.js +131 -0
- package/dist/util/resolution/tsconfig.js.map +1 -0
- package/dist/util/resolution.d.ts +37 -0
- package/dist/util/resolution.d.ts.map +1 -0
- package/dist/util/resolution.js +276 -0
- package/dist/util/resolution.js.map +1 -0
- package/dist/util/resolutionCandidates.d.ts +5 -0
- package/dist/util/resolutionCandidates.d.ts.map +1 -0
- package/dist/util/resolutionCandidates.js +70 -0
- package/dist/util/resolutionCandidates.js.map +1 -0
- package/dist/util/rustTestModules.d.ts +3 -0
- package/dist/util/rustTestModules.d.ts.map +1 -0
- package/dist/util/rustTestModules.js +69 -0
- package/dist/util/rustTestModules.js.map +1 -0
- package/dist/util/semaphore.d.ts +2 -0
- package/dist/util/semaphore.d.ts.map +1 -0
- package/dist/util/semaphore.js +2 -0
- package/dist/util/semaphore.js.map +1 -0
- package/dist/util/sourceLocation.d.ts +8 -0
- package/dist/util/sourceLocation.d.ts.map +1 -0
- package/dist/util/sourceLocation.js +19 -0
- package/dist/util/sourceLocation.js.map +1 -0
- package/dist/util/specifiers.d.ts +17 -0
- package/dist/util/specifiers.d.ts.map +1 -0
- package/dist/util/specifiers.js +263 -0
- package/dist/util/specifiers.js.map +1 -0
- package/dist/util/sqliteSchema.d.ts +28 -0
- package/dist/util/sqliteSchema.d.ts.map +1 -0
- package/dist/util/sqliteSchema.js +66 -0
- package/dist/util/sqliteSchema.js.map +1 -0
- package/dist/util/symbolHash.d.ts +59 -0
- package/dist/util/symbolHash.d.ts.map +1 -0
- package/dist/util/symbolHash.js +84 -0
- package/dist/util/symbolHash.js.map +1 -0
- package/dist/util/workerThreads.d.ts +12 -0
- package/dist/util/workerThreads.d.ts.map +1 -0
- package/dist/util/workerThreads.js +16 -0
- package/dist/util/workerThreads.js.map +1 -0
- package/dist/util/workspace.d.ts +32 -0
- package/dist/util/workspace.d.ts.map +1 -0
- package/dist/util/workspace.js +288 -0
- package/dist/util/workspace.js.map +1 -0
- package/dist/util.d.ts +14 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +10 -0
- package/dist/util.js.map +1 -0
- package/dist/worker/nativeExtractWorker.d.ts +61 -0
- package/dist/worker/nativeExtractWorker.d.ts.map +1 -0
- package/dist/worker/nativeExtractWorker.js +196 -0
- package/dist/worker/nativeExtractWorker.js.map +1 -0
- package/dist/worker/nativeWorkerPool.d.ts +10 -0
- package/dist/worker/nativeWorkerPool.d.ts.map +1 -0
- package/dist/worker/nativeWorkerPool.js +35 -0
- package/dist/worker/nativeWorkerPool.js.map +1 -0
- package/docs/graph-visualization/app.js +900 -0
- package/docs/graph-visualization/file-tree-filters.js +50 -0
- package/docs/graph-visualization/file-tree-model.js +186 -0
- package/docs/graph-visualization/graph-builder.js +303 -0
- package/docs/graph-visualization/index.html +65 -0
- package/docs/graph-visualization/styles.css +513 -0
- package/docs/graph-visualization/vendor/LICENSE.graphology-layout-forceatlas2.txt +21 -0
- package/docs/graph-visualization/vendor/LICENSE.graphology.txt +21 -0
- package/docs/graph-visualization/vendor/LICENSE.sigma.txt +12 -0
- package/docs/graph-visualization/vendor/graphology-layout-forceatlas2.js +789 -0
- package/docs/graph-visualization/vendor/graphology.js +4204 -0
- package/docs/graph-visualization/vendor/sigma.js +5643 -0
- package/docs/graph-visualization/viewer-selected-node.webp +0 -0
- package/docs/mcp.md +373 -0
- package/package.json +104 -0
|
@@ -0,0 +1,4204 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) =>
|
|
8
|
+
function __require() {
|
|
9
|
+
return (mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports);
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (
|
|
23
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
24
|
+
__copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod,
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// node_modules/events/events.js
|
|
35
|
+
var require_events = __commonJS({
|
|
36
|
+
"node_modules/events/events.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var R = typeof Reflect === "object" ? Reflect : null;
|
|
39
|
+
var ReflectApply =
|
|
40
|
+
R && typeof R.apply === "function"
|
|
41
|
+
? R.apply
|
|
42
|
+
: function ReflectApply2(target, receiver, args) {
|
|
43
|
+
return Function.prototype.apply.call(target, receiver, args);
|
|
44
|
+
};
|
|
45
|
+
var ReflectOwnKeys;
|
|
46
|
+
if (R && typeof R.ownKeys === "function") {
|
|
47
|
+
ReflectOwnKeys = R.ownKeys;
|
|
48
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
49
|
+
ReflectOwnKeys = function ReflectOwnKeys2(target) {
|
|
50
|
+
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
ReflectOwnKeys = function ReflectOwnKeys2(target) {
|
|
54
|
+
return Object.getOwnPropertyNames(target);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function ProcessEmitWarning(warning) {
|
|
58
|
+
if (console && console.warn) console.warn(warning);
|
|
59
|
+
}
|
|
60
|
+
var NumberIsNaN =
|
|
61
|
+
Number.isNaN ||
|
|
62
|
+
function NumberIsNaN2(value) {
|
|
63
|
+
return value !== value;
|
|
64
|
+
};
|
|
65
|
+
function EventEmitter2() {
|
|
66
|
+
EventEmitter2.init.call(this);
|
|
67
|
+
}
|
|
68
|
+
module.exports = EventEmitter2;
|
|
69
|
+
module.exports.once = once;
|
|
70
|
+
EventEmitter2.EventEmitter = EventEmitter2;
|
|
71
|
+
EventEmitter2.prototype._events = void 0;
|
|
72
|
+
EventEmitter2.prototype._eventsCount = 0;
|
|
73
|
+
EventEmitter2.prototype._maxListeners = void 0;
|
|
74
|
+
var defaultMaxListeners = 10;
|
|
75
|
+
function checkListener(listener) {
|
|
76
|
+
if (typeof listener !== "function") {
|
|
77
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
Object.defineProperty(EventEmitter2, "defaultMaxListeners", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return defaultMaxListeners;
|
|
84
|
+
},
|
|
85
|
+
set: function (arg) {
|
|
86
|
+
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) {
|
|
87
|
+
throw new RangeError(
|
|
88
|
+
'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' +
|
|
89
|
+
arg +
|
|
90
|
+
".",
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
defaultMaxListeners = arg;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
EventEmitter2.init = function () {
|
|
97
|
+
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
|
|
98
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
99
|
+
this._eventsCount = 0;
|
|
100
|
+
}
|
|
101
|
+
this._maxListeners = this._maxListeners || void 0;
|
|
102
|
+
};
|
|
103
|
+
EventEmitter2.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
104
|
+
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) {
|
|
105
|
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
|
|
106
|
+
}
|
|
107
|
+
this._maxListeners = n;
|
|
108
|
+
return this;
|
|
109
|
+
};
|
|
110
|
+
function _getMaxListeners(that) {
|
|
111
|
+
if (that._maxListeners === void 0) return EventEmitter2.defaultMaxListeners;
|
|
112
|
+
return that._maxListeners;
|
|
113
|
+
}
|
|
114
|
+
EventEmitter2.prototype.getMaxListeners = function getMaxListeners() {
|
|
115
|
+
return _getMaxListeners(this);
|
|
116
|
+
};
|
|
117
|
+
EventEmitter2.prototype.emit = function emit(type) {
|
|
118
|
+
var args = [];
|
|
119
|
+
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
|
120
|
+
var doError = type === "error";
|
|
121
|
+
var events = this._events;
|
|
122
|
+
if (events !== void 0) doError = doError && events.error === void 0;
|
|
123
|
+
else if (!doError) return false;
|
|
124
|
+
if (doError) {
|
|
125
|
+
var er;
|
|
126
|
+
if (args.length > 0) er = args[0];
|
|
127
|
+
if (er instanceof Error) {
|
|
128
|
+
throw er;
|
|
129
|
+
}
|
|
130
|
+
var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
|
|
131
|
+
err.context = er;
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
134
|
+
var handler = events[type];
|
|
135
|
+
if (handler === void 0) return false;
|
|
136
|
+
if (typeof handler === "function") {
|
|
137
|
+
ReflectApply(handler, this, args);
|
|
138
|
+
} else {
|
|
139
|
+
var len = handler.length;
|
|
140
|
+
var listeners = arrayClone(handler, len);
|
|
141
|
+
for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
};
|
|
145
|
+
function _addListener(target, type, listener, prepend) {
|
|
146
|
+
var m;
|
|
147
|
+
var events;
|
|
148
|
+
var existing;
|
|
149
|
+
checkListener(listener);
|
|
150
|
+
events = target._events;
|
|
151
|
+
if (events === void 0) {
|
|
152
|
+
events = target._events = /* @__PURE__ */ Object.create(null);
|
|
153
|
+
target._eventsCount = 0;
|
|
154
|
+
} else {
|
|
155
|
+
if (events.newListener !== void 0) {
|
|
156
|
+
target.emit("newListener", type, listener.listener ? listener.listener : listener);
|
|
157
|
+
events = target._events;
|
|
158
|
+
}
|
|
159
|
+
existing = events[type];
|
|
160
|
+
}
|
|
161
|
+
if (existing === void 0) {
|
|
162
|
+
existing = events[type] = listener;
|
|
163
|
+
++target._eventsCount;
|
|
164
|
+
} else {
|
|
165
|
+
if (typeof existing === "function") {
|
|
166
|
+
existing = events[type] = prepend ? [listener, existing] : [existing, listener];
|
|
167
|
+
} else if (prepend) {
|
|
168
|
+
existing.unshift(listener);
|
|
169
|
+
} else {
|
|
170
|
+
existing.push(listener);
|
|
171
|
+
}
|
|
172
|
+
m = _getMaxListeners(target);
|
|
173
|
+
if (m > 0 && existing.length > m && !existing.warned) {
|
|
174
|
+
existing.warned = true;
|
|
175
|
+
var w = new Error(
|
|
176
|
+
"Possible EventEmitter memory leak detected. " +
|
|
177
|
+
existing.length +
|
|
178
|
+
" " +
|
|
179
|
+
String(type) +
|
|
180
|
+
" listeners added. Use emitter.setMaxListeners() to increase limit",
|
|
181
|
+
);
|
|
182
|
+
w.name = "MaxListenersExceededWarning";
|
|
183
|
+
w.emitter = target;
|
|
184
|
+
w.type = type;
|
|
185
|
+
w.count = existing.length;
|
|
186
|
+
ProcessEmitWarning(w);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return target;
|
|
190
|
+
}
|
|
191
|
+
EventEmitter2.prototype.addListener = function addListener(type, listener) {
|
|
192
|
+
return _addListener(this, type, listener, false);
|
|
193
|
+
};
|
|
194
|
+
EventEmitter2.prototype.on = EventEmitter2.prototype.addListener;
|
|
195
|
+
EventEmitter2.prototype.prependListener = function prependListener(type, listener) {
|
|
196
|
+
return _addListener(this, type, listener, true);
|
|
197
|
+
};
|
|
198
|
+
function onceWrapper() {
|
|
199
|
+
if (!this.fired) {
|
|
200
|
+
this.target.removeListener(this.type, this.wrapFn);
|
|
201
|
+
this.fired = true;
|
|
202
|
+
if (arguments.length === 0) return this.listener.call(this.target);
|
|
203
|
+
return this.listener.apply(this.target, arguments);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function _onceWrap(target, type, listener) {
|
|
207
|
+
var state = { fired: false, wrapFn: void 0, target, type, listener };
|
|
208
|
+
var wrapped = onceWrapper.bind(state);
|
|
209
|
+
wrapped.listener = listener;
|
|
210
|
+
state.wrapFn = wrapped;
|
|
211
|
+
return wrapped;
|
|
212
|
+
}
|
|
213
|
+
EventEmitter2.prototype.once = function once2(type, listener) {
|
|
214
|
+
checkListener(listener);
|
|
215
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
216
|
+
return this;
|
|
217
|
+
};
|
|
218
|
+
EventEmitter2.prototype.prependOnceListener = function prependOnceListener(type, listener) {
|
|
219
|
+
checkListener(listener);
|
|
220
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
221
|
+
return this;
|
|
222
|
+
};
|
|
223
|
+
EventEmitter2.prototype.removeListener = function removeListener(type, listener) {
|
|
224
|
+
var list, events, position, i, originalListener;
|
|
225
|
+
checkListener(listener);
|
|
226
|
+
events = this._events;
|
|
227
|
+
if (events === void 0) return this;
|
|
228
|
+
list = events[type];
|
|
229
|
+
if (list === void 0) return this;
|
|
230
|
+
if (list === listener || list.listener === listener) {
|
|
231
|
+
if (--this._eventsCount === 0) this._events = /* @__PURE__ */ Object.create(null);
|
|
232
|
+
else {
|
|
233
|
+
delete events[type];
|
|
234
|
+
if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
|
|
235
|
+
}
|
|
236
|
+
} else if (typeof list !== "function") {
|
|
237
|
+
position = -1;
|
|
238
|
+
for (i = list.length - 1; i >= 0; i--) {
|
|
239
|
+
if (list[i] === listener || list[i].listener === listener) {
|
|
240
|
+
originalListener = list[i].listener;
|
|
241
|
+
position = i;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (position < 0) return this;
|
|
246
|
+
if (position === 0) list.shift();
|
|
247
|
+
else {
|
|
248
|
+
spliceOne(list, position);
|
|
249
|
+
}
|
|
250
|
+
if (list.length === 1) events[type] = list[0];
|
|
251
|
+
if (events.removeListener !== void 0) this.emit("removeListener", type, originalListener || listener);
|
|
252
|
+
}
|
|
253
|
+
return this;
|
|
254
|
+
};
|
|
255
|
+
EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
|
|
256
|
+
EventEmitter2.prototype.removeAllListeners = function removeAllListeners(type) {
|
|
257
|
+
var listeners, events, i;
|
|
258
|
+
events = this._events;
|
|
259
|
+
if (events === void 0) return this;
|
|
260
|
+
if (events.removeListener === void 0) {
|
|
261
|
+
if (arguments.length === 0) {
|
|
262
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
263
|
+
this._eventsCount = 0;
|
|
264
|
+
} else if (events[type] !== void 0) {
|
|
265
|
+
if (--this._eventsCount === 0) this._events = /* @__PURE__ */ Object.create(null);
|
|
266
|
+
else delete events[type];
|
|
267
|
+
}
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
if (arguments.length === 0) {
|
|
271
|
+
var keys = Object.keys(events);
|
|
272
|
+
var key;
|
|
273
|
+
for (i = 0; i < keys.length; ++i) {
|
|
274
|
+
key = keys[i];
|
|
275
|
+
if (key === "removeListener") continue;
|
|
276
|
+
this.removeAllListeners(key);
|
|
277
|
+
}
|
|
278
|
+
this.removeAllListeners("removeListener");
|
|
279
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
280
|
+
this._eventsCount = 0;
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
listeners = events[type];
|
|
284
|
+
if (typeof listeners === "function") {
|
|
285
|
+
this.removeListener(type, listeners);
|
|
286
|
+
} else if (listeners !== void 0) {
|
|
287
|
+
for (i = listeners.length - 1; i >= 0; i--) {
|
|
288
|
+
this.removeListener(type, listeners[i]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return this;
|
|
292
|
+
};
|
|
293
|
+
function _listeners(target, type, unwrap) {
|
|
294
|
+
var events = target._events;
|
|
295
|
+
if (events === void 0) return [];
|
|
296
|
+
var evlistener = events[type];
|
|
297
|
+
if (evlistener === void 0) return [];
|
|
298
|
+
if (typeof evlistener === "function") return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
|
299
|
+
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
|
300
|
+
}
|
|
301
|
+
EventEmitter2.prototype.listeners = function listeners(type) {
|
|
302
|
+
return _listeners(this, type, true);
|
|
303
|
+
};
|
|
304
|
+
EventEmitter2.prototype.rawListeners = function rawListeners(type) {
|
|
305
|
+
return _listeners(this, type, false);
|
|
306
|
+
};
|
|
307
|
+
EventEmitter2.listenerCount = function (emitter, type) {
|
|
308
|
+
if (typeof emitter.listenerCount === "function") {
|
|
309
|
+
return emitter.listenerCount(type);
|
|
310
|
+
} else {
|
|
311
|
+
return listenerCount.call(emitter, type);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
EventEmitter2.prototype.listenerCount = listenerCount;
|
|
315
|
+
function listenerCount(type) {
|
|
316
|
+
var events = this._events;
|
|
317
|
+
if (events !== void 0) {
|
|
318
|
+
var evlistener = events[type];
|
|
319
|
+
if (typeof evlistener === "function") {
|
|
320
|
+
return 1;
|
|
321
|
+
} else if (evlistener !== void 0) {
|
|
322
|
+
return evlistener.length;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
EventEmitter2.prototype.eventNames = function eventNames() {
|
|
328
|
+
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
|
329
|
+
};
|
|
330
|
+
function arrayClone(arr, n) {
|
|
331
|
+
var copy = new Array(n);
|
|
332
|
+
for (var i = 0; i < n; ++i) copy[i] = arr[i];
|
|
333
|
+
return copy;
|
|
334
|
+
}
|
|
335
|
+
function spliceOne(list, index) {
|
|
336
|
+
for (; index + 1 < list.length; index++) list[index] = list[index + 1];
|
|
337
|
+
list.pop();
|
|
338
|
+
}
|
|
339
|
+
function unwrapListeners(arr) {
|
|
340
|
+
var ret = new Array(arr.length);
|
|
341
|
+
for (var i = 0; i < ret.length; ++i) {
|
|
342
|
+
ret[i] = arr[i].listener || arr[i];
|
|
343
|
+
}
|
|
344
|
+
return ret;
|
|
345
|
+
}
|
|
346
|
+
function once(emitter, name) {
|
|
347
|
+
return new Promise(function (resolve, reject) {
|
|
348
|
+
function errorListener(err) {
|
|
349
|
+
emitter.removeListener(name, resolver);
|
|
350
|
+
reject(err);
|
|
351
|
+
}
|
|
352
|
+
function resolver() {
|
|
353
|
+
if (typeof emitter.removeListener === "function") {
|
|
354
|
+
emitter.removeListener("error", errorListener);
|
|
355
|
+
}
|
|
356
|
+
resolve([].slice.call(arguments));
|
|
357
|
+
}
|
|
358
|
+
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
|
359
|
+
if (name !== "error") {
|
|
360
|
+
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
|
|
365
|
+
if (typeof emitter.on === "function") {
|
|
366
|
+
eventTargetAgnosticAddListener(emitter, "error", handler, flags);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
370
|
+
if (typeof emitter.on === "function") {
|
|
371
|
+
if (flags.once) {
|
|
372
|
+
emitter.once(name, listener);
|
|
373
|
+
} else {
|
|
374
|
+
emitter.on(name, listener);
|
|
375
|
+
}
|
|
376
|
+
} else if (typeof emitter.addEventListener === "function") {
|
|
377
|
+
emitter.addEventListener(name, function wrapListener(arg) {
|
|
378
|
+
if (flags.once) {
|
|
379
|
+
emitter.removeEventListener(name, wrapListener);
|
|
380
|
+
}
|
|
381
|
+
listener(arg);
|
|
382
|
+
});
|
|
383
|
+
} else {
|
|
384
|
+
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// node_modules/graphology/dist/graphology.esm.js
|
|
391
|
+
var import_events = __toESM(require_events());
|
|
392
|
+
function assignPolyfill() {
|
|
393
|
+
const target = arguments[0];
|
|
394
|
+
for (let i = 1, l = arguments.length; i < l; i++) {
|
|
395
|
+
if (!arguments[i]) continue;
|
|
396
|
+
for (const k in arguments[i]) target[k] = arguments[i][k];
|
|
397
|
+
}
|
|
398
|
+
return target;
|
|
399
|
+
}
|
|
400
|
+
var assign = assignPolyfill;
|
|
401
|
+
if (typeof Object.assign === "function") assign = Object.assign;
|
|
402
|
+
function getMatchingEdge(graph, source, target, type) {
|
|
403
|
+
const sourceData = graph._nodes.get(source);
|
|
404
|
+
let edge = null;
|
|
405
|
+
if (!sourceData) return edge;
|
|
406
|
+
if (type === "mixed") {
|
|
407
|
+
edge = (sourceData.out && sourceData.out[target]) || (sourceData.undirected && sourceData.undirected[target]);
|
|
408
|
+
} else if (type === "directed") {
|
|
409
|
+
edge = sourceData.out && sourceData.out[target];
|
|
410
|
+
} else {
|
|
411
|
+
edge = sourceData.undirected && sourceData.undirected[target];
|
|
412
|
+
}
|
|
413
|
+
return edge;
|
|
414
|
+
}
|
|
415
|
+
function isPlainObject(value) {
|
|
416
|
+
return typeof value === "object" && value !== null;
|
|
417
|
+
}
|
|
418
|
+
function isEmpty(o) {
|
|
419
|
+
let k;
|
|
420
|
+
for (k in o) return false;
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
function privateProperty(target, name, value) {
|
|
424
|
+
Object.defineProperty(target, name, {
|
|
425
|
+
enumerable: false,
|
|
426
|
+
configurable: false,
|
|
427
|
+
writable: true,
|
|
428
|
+
value,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function readOnlyProperty(target, name, value) {
|
|
432
|
+
const descriptor = {
|
|
433
|
+
enumerable: true,
|
|
434
|
+
configurable: true,
|
|
435
|
+
};
|
|
436
|
+
if (typeof value === "function") {
|
|
437
|
+
descriptor.get = value;
|
|
438
|
+
} else {
|
|
439
|
+
descriptor.value = value;
|
|
440
|
+
descriptor.writable = false;
|
|
441
|
+
}
|
|
442
|
+
Object.defineProperty(target, name, descriptor);
|
|
443
|
+
}
|
|
444
|
+
function validateHints(hints) {
|
|
445
|
+
if (!isPlainObject(hints)) return false;
|
|
446
|
+
if (hints.attributes && !Array.isArray(hints.attributes)) return false;
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
function incrementalIdStartingFromRandomByte() {
|
|
450
|
+
let i = Math.floor(Math.random() * 256) & 255;
|
|
451
|
+
return () => {
|
|
452
|
+
return i++;
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function chain() {
|
|
456
|
+
const iterables = arguments;
|
|
457
|
+
let current = null;
|
|
458
|
+
let i = -1;
|
|
459
|
+
return {
|
|
460
|
+
[Symbol.iterator]() {
|
|
461
|
+
return this;
|
|
462
|
+
},
|
|
463
|
+
next() {
|
|
464
|
+
let step = null;
|
|
465
|
+
do {
|
|
466
|
+
if (current === null) {
|
|
467
|
+
i++;
|
|
468
|
+
if (i >= iterables.length) return { done: true };
|
|
469
|
+
current = iterables[i][Symbol.iterator]();
|
|
470
|
+
}
|
|
471
|
+
step = current.next();
|
|
472
|
+
if (step.done) {
|
|
473
|
+
current = null;
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
break;
|
|
477
|
+
} while (true);
|
|
478
|
+
return step;
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function emptyIterator() {
|
|
483
|
+
return {
|
|
484
|
+
[Symbol.iterator]() {
|
|
485
|
+
return this;
|
|
486
|
+
},
|
|
487
|
+
next() {
|
|
488
|
+
return { done: true };
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
var GraphError = class extends Error {
|
|
493
|
+
constructor(message) {
|
|
494
|
+
super();
|
|
495
|
+
this.name = "GraphError";
|
|
496
|
+
this.message = message;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
var InvalidArgumentsGraphError = class _InvalidArgumentsGraphError extends GraphError {
|
|
500
|
+
constructor(message) {
|
|
501
|
+
super(message);
|
|
502
|
+
this.name = "InvalidArgumentsGraphError";
|
|
503
|
+
if (typeof Error.captureStackTrace === "function")
|
|
504
|
+
Error.captureStackTrace(this, _InvalidArgumentsGraphError.prototype.constructor);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
var NotFoundGraphError = class _NotFoundGraphError extends GraphError {
|
|
508
|
+
constructor(message) {
|
|
509
|
+
super(message);
|
|
510
|
+
this.name = "NotFoundGraphError";
|
|
511
|
+
if (typeof Error.captureStackTrace === "function")
|
|
512
|
+
Error.captureStackTrace(this, _NotFoundGraphError.prototype.constructor);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
var UsageGraphError = class _UsageGraphError extends GraphError {
|
|
516
|
+
constructor(message) {
|
|
517
|
+
super(message);
|
|
518
|
+
this.name = "UsageGraphError";
|
|
519
|
+
if (typeof Error.captureStackTrace === "function")
|
|
520
|
+
Error.captureStackTrace(this, _UsageGraphError.prototype.constructor);
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
function MixedNodeData(key, attributes) {
|
|
524
|
+
this.key = key;
|
|
525
|
+
this.attributes = attributes;
|
|
526
|
+
this.clear();
|
|
527
|
+
}
|
|
528
|
+
MixedNodeData.prototype.clear = function () {
|
|
529
|
+
this.inDegree = 0;
|
|
530
|
+
this.outDegree = 0;
|
|
531
|
+
this.undirectedDegree = 0;
|
|
532
|
+
this.undirectedLoops = 0;
|
|
533
|
+
this.directedLoops = 0;
|
|
534
|
+
this.in = {};
|
|
535
|
+
this.out = {};
|
|
536
|
+
this.undirected = {};
|
|
537
|
+
};
|
|
538
|
+
function DirectedNodeData(key, attributes) {
|
|
539
|
+
this.key = key;
|
|
540
|
+
this.attributes = attributes;
|
|
541
|
+
this.clear();
|
|
542
|
+
}
|
|
543
|
+
DirectedNodeData.prototype.clear = function () {
|
|
544
|
+
this.inDegree = 0;
|
|
545
|
+
this.outDegree = 0;
|
|
546
|
+
this.directedLoops = 0;
|
|
547
|
+
this.in = {};
|
|
548
|
+
this.out = {};
|
|
549
|
+
};
|
|
550
|
+
function UndirectedNodeData(key, attributes) {
|
|
551
|
+
this.key = key;
|
|
552
|
+
this.attributes = attributes;
|
|
553
|
+
this.clear();
|
|
554
|
+
}
|
|
555
|
+
UndirectedNodeData.prototype.clear = function () {
|
|
556
|
+
this.undirectedDegree = 0;
|
|
557
|
+
this.undirectedLoops = 0;
|
|
558
|
+
this.undirected = {};
|
|
559
|
+
};
|
|
560
|
+
function EdgeData(undirected, key, source, target, attributes) {
|
|
561
|
+
this.key = key;
|
|
562
|
+
this.attributes = attributes;
|
|
563
|
+
this.undirected = undirected;
|
|
564
|
+
this.source = source;
|
|
565
|
+
this.target = target;
|
|
566
|
+
}
|
|
567
|
+
EdgeData.prototype.attach = function () {
|
|
568
|
+
let outKey = "out";
|
|
569
|
+
let inKey = "in";
|
|
570
|
+
if (this.undirected) outKey = inKey = "undirected";
|
|
571
|
+
const source = this.source.key;
|
|
572
|
+
const target = this.target.key;
|
|
573
|
+
this.source[outKey][target] = this;
|
|
574
|
+
if (this.undirected && source === target) return;
|
|
575
|
+
this.target[inKey][source] = this;
|
|
576
|
+
};
|
|
577
|
+
EdgeData.prototype.attachMulti = function () {
|
|
578
|
+
let outKey = "out";
|
|
579
|
+
let inKey = "in";
|
|
580
|
+
const source = this.source.key;
|
|
581
|
+
const target = this.target.key;
|
|
582
|
+
if (this.undirected) outKey = inKey = "undirected";
|
|
583
|
+
const adj = this.source[outKey];
|
|
584
|
+
const head = adj[target];
|
|
585
|
+
if (typeof head === "undefined") {
|
|
586
|
+
adj[target] = this;
|
|
587
|
+
if (!(this.undirected && source === target)) {
|
|
588
|
+
this.target[inKey][source] = this;
|
|
589
|
+
}
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
head.previous = this;
|
|
593
|
+
this.next = head;
|
|
594
|
+
adj[target] = this;
|
|
595
|
+
this.target[inKey][source] = this;
|
|
596
|
+
};
|
|
597
|
+
EdgeData.prototype.detach = function () {
|
|
598
|
+
const source = this.source.key;
|
|
599
|
+
const target = this.target.key;
|
|
600
|
+
let outKey = "out";
|
|
601
|
+
let inKey = "in";
|
|
602
|
+
if (this.undirected) outKey = inKey = "undirected";
|
|
603
|
+
delete this.source[outKey][target];
|
|
604
|
+
delete this.target[inKey][source];
|
|
605
|
+
};
|
|
606
|
+
EdgeData.prototype.detachMulti = function () {
|
|
607
|
+
const source = this.source.key;
|
|
608
|
+
const target = this.target.key;
|
|
609
|
+
let outKey = "out";
|
|
610
|
+
let inKey = "in";
|
|
611
|
+
if (this.undirected) outKey = inKey = "undirected";
|
|
612
|
+
if (this.previous === void 0) {
|
|
613
|
+
if (this.next === void 0) {
|
|
614
|
+
delete this.source[outKey][target];
|
|
615
|
+
delete this.target[inKey][source];
|
|
616
|
+
} else {
|
|
617
|
+
this.next.previous = void 0;
|
|
618
|
+
this.source[outKey][target] = this.next;
|
|
619
|
+
this.target[inKey][source] = this.next;
|
|
620
|
+
}
|
|
621
|
+
} else {
|
|
622
|
+
this.previous.next = this.next;
|
|
623
|
+
if (this.next !== void 0) {
|
|
624
|
+
this.next.previous = this.previous;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var NODE = 0;
|
|
629
|
+
var SOURCE = 1;
|
|
630
|
+
var TARGET = 2;
|
|
631
|
+
var OPPOSITE = 3;
|
|
632
|
+
function findRelevantNodeData(graph, method, mode, nodeOrEdge, nameOrEdge, add1, add2) {
|
|
633
|
+
let nodeData, edgeData, arg1, arg2;
|
|
634
|
+
nodeOrEdge = "" + nodeOrEdge;
|
|
635
|
+
if (mode === NODE) {
|
|
636
|
+
nodeData = graph._nodes.get(nodeOrEdge);
|
|
637
|
+
if (!nodeData)
|
|
638
|
+
throw new NotFoundGraphError(`Graph.${method}: could not find the "${nodeOrEdge}" node in the graph.`);
|
|
639
|
+
arg1 = nameOrEdge;
|
|
640
|
+
arg2 = add1;
|
|
641
|
+
} else if (mode === OPPOSITE) {
|
|
642
|
+
nameOrEdge = "" + nameOrEdge;
|
|
643
|
+
edgeData = graph._edges.get(nameOrEdge);
|
|
644
|
+
if (!edgeData)
|
|
645
|
+
throw new NotFoundGraphError(`Graph.${method}: could not find the "${nameOrEdge}" edge in the graph.`);
|
|
646
|
+
const source = edgeData.source.key;
|
|
647
|
+
const target = edgeData.target.key;
|
|
648
|
+
if (nodeOrEdge === source) {
|
|
649
|
+
nodeData = edgeData.target;
|
|
650
|
+
} else if (nodeOrEdge === target) {
|
|
651
|
+
nodeData = edgeData.source;
|
|
652
|
+
} else {
|
|
653
|
+
throw new NotFoundGraphError(
|
|
654
|
+
`Graph.${method}: the "${nodeOrEdge}" node is not attached to the "${nameOrEdge}" edge (${source}, ${target}).`,
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
arg1 = add1;
|
|
658
|
+
arg2 = add2;
|
|
659
|
+
} else {
|
|
660
|
+
edgeData = graph._edges.get(nodeOrEdge);
|
|
661
|
+
if (!edgeData)
|
|
662
|
+
throw new NotFoundGraphError(`Graph.${method}: could not find the "${nodeOrEdge}" edge in the graph.`);
|
|
663
|
+
if (mode === SOURCE) {
|
|
664
|
+
nodeData = edgeData.source;
|
|
665
|
+
} else {
|
|
666
|
+
nodeData = edgeData.target;
|
|
667
|
+
}
|
|
668
|
+
arg1 = nameOrEdge;
|
|
669
|
+
arg2 = add1;
|
|
670
|
+
}
|
|
671
|
+
return [nodeData, arg1, arg2];
|
|
672
|
+
}
|
|
673
|
+
function attachNodeAttributeGetter(Class, method, mode) {
|
|
674
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
675
|
+
const [data, name] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
676
|
+
return data.attributes[name];
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function attachNodeAttributesGetter(Class, method, mode) {
|
|
680
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge) {
|
|
681
|
+
const [data] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge);
|
|
682
|
+
return data.attributes;
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function attachNodeAttributeChecker(Class, method, mode) {
|
|
686
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
687
|
+
const [data, name] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
688
|
+
return data.attributes.hasOwnProperty(name);
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function attachNodeAttributeSetter(Class, method, mode) {
|
|
692
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1, add2) {
|
|
693
|
+
const [data, name, value] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1, add2);
|
|
694
|
+
data.attributes[name] = value;
|
|
695
|
+
this.emit("nodeAttributesUpdated", {
|
|
696
|
+
key: data.key,
|
|
697
|
+
type: "set",
|
|
698
|
+
attributes: data.attributes,
|
|
699
|
+
name,
|
|
700
|
+
});
|
|
701
|
+
return this;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
function attachNodeAttributeUpdater(Class, method, mode) {
|
|
705
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1, add2) {
|
|
706
|
+
const [data, name, updater] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1, add2);
|
|
707
|
+
if (typeof updater !== "function")
|
|
708
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: updater should be a function.`);
|
|
709
|
+
const attributes = data.attributes;
|
|
710
|
+
const value = updater(attributes[name]);
|
|
711
|
+
attributes[name] = value;
|
|
712
|
+
this.emit("nodeAttributesUpdated", {
|
|
713
|
+
key: data.key,
|
|
714
|
+
type: "set",
|
|
715
|
+
attributes: data.attributes,
|
|
716
|
+
name,
|
|
717
|
+
});
|
|
718
|
+
return this;
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
function attachNodeAttributeRemover(Class, method, mode) {
|
|
722
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
723
|
+
const [data, name] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
724
|
+
delete data.attributes[name];
|
|
725
|
+
this.emit("nodeAttributesUpdated", {
|
|
726
|
+
key: data.key,
|
|
727
|
+
type: "remove",
|
|
728
|
+
attributes: data.attributes,
|
|
729
|
+
name,
|
|
730
|
+
});
|
|
731
|
+
return this;
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function attachNodeAttributesReplacer(Class, method, mode) {
|
|
735
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
736
|
+
const [data, attributes] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
737
|
+
if (!isPlainObject(attributes))
|
|
738
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided attributes are not a plain object.`);
|
|
739
|
+
data.attributes = attributes;
|
|
740
|
+
this.emit("nodeAttributesUpdated", {
|
|
741
|
+
key: data.key,
|
|
742
|
+
type: "replace",
|
|
743
|
+
attributes: data.attributes,
|
|
744
|
+
});
|
|
745
|
+
return this;
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function attachNodeAttributesMerger(Class, method, mode) {
|
|
749
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
750
|
+
const [data, attributes] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
751
|
+
if (!isPlainObject(attributes))
|
|
752
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided attributes are not a plain object.`);
|
|
753
|
+
assign(data.attributes, attributes);
|
|
754
|
+
this.emit("nodeAttributesUpdated", {
|
|
755
|
+
key: data.key,
|
|
756
|
+
type: "merge",
|
|
757
|
+
attributes: data.attributes,
|
|
758
|
+
data: attributes,
|
|
759
|
+
});
|
|
760
|
+
return this;
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function attachNodeAttributesUpdater(Class, method, mode) {
|
|
764
|
+
Class.prototype[method] = function (nodeOrEdge, nameOrEdge, add1) {
|
|
765
|
+
const [data, updater] = findRelevantNodeData(this, method, mode, nodeOrEdge, nameOrEdge, add1);
|
|
766
|
+
if (typeof updater !== "function")
|
|
767
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided updater is not a function.`);
|
|
768
|
+
data.attributes = updater(data.attributes);
|
|
769
|
+
this.emit("nodeAttributesUpdated", {
|
|
770
|
+
key: data.key,
|
|
771
|
+
type: "update",
|
|
772
|
+
attributes: data.attributes,
|
|
773
|
+
});
|
|
774
|
+
return this;
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
var NODE_ATTRIBUTES_METHODS = [
|
|
778
|
+
{
|
|
779
|
+
name: (element) => `get${element}Attribute`,
|
|
780
|
+
attacher: attachNodeAttributeGetter,
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
name: (element) => `get${element}Attributes`,
|
|
784
|
+
attacher: attachNodeAttributesGetter,
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
name: (element) => `has${element}Attribute`,
|
|
788
|
+
attacher: attachNodeAttributeChecker,
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
name: (element) => `set${element}Attribute`,
|
|
792
|
+
attacher: attachNodeAttributeSetter,
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
name: (element) => `update${element}Attribute`,
|
|
796
|
+
attacher: attachNodeAttributeUpdater,
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
name: (element) => `remove${element}Attribute`,
|
|
800
|
+
attacher: attachNodeAttributeRemover,
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
name: (element) => `replace${element}Attributes`,
|
|
804
|
+
attacher: attachNodeAttributesReplacer,
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: (element) => `merge${element}Attributes`,
|
|
808
|
+
attacher: attachNodeAttributesMerger,
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
name: (element) => `update${element}Attributes`,
|
|
812
|
+
attacher: attachNodeAttributesUpdater,
|
|
813
|
+
},
|
|
814
|
+
];
|
|
815
|
+
function attachNodeAttributesMethods(Graph2) {
|
|
816
|
+
NODE_ATTRIBUTES_METHODS.forEach(function ({ name, attacher }) {
|
|
817
|
+
attacher(Graph2, name("Node"), NODE);
|
|
818
|
+
attacher(Graph2, name("Source"), SOURCE);
|
|
819
|
+
attacher(Graph2, name("Target"), TARGET);
|
|
820
|
+
attacher(Graph2, name("Opposite"), OPPOSITE);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function attachEdgeAttributeGetter(Class, method, type) {
|
|
824
|
+
Class.prototype[method] = function (element, name) {
|
|
825
|
+
let data;
|
|
826
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
827
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
828
|
+
if (arguments.length > 2) {
|
|
829
|
+
if (this.multi)
|
|
830
|
+
throw new UsageGraphError(
|
|
831
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
832
|
+
);
|
|
833
|
+
const source = "" + element;
|
|
834
|
+
const target = "" + name;
|
|
835
|
+
name = arguments[2];
|
|
836
|
+
data = getMatchingEdge(this, source, target, type);
|
|
837
|
+
if (!data)
|
|
838
|
+
throw new NotFoundGraphError(
|
|
839
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
840
|
+
);
|
|
841
|
+
} else {
|
|
842
|
+
if (type !== "mixed")
|
|
843
|
+
throw new UsageGraphError(
|
|
844
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
845
|
+
);
|
|
846
|
+
element = "" + element;
|
|
847
|
+
data = this._edges.get(element);
|
|
848
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
849
|
+
}
|
|
850
|
+
return data.attributes[name];
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function attachEdgeAttributesGetter(Class, method, type) {
|
|
854
|
+
Class.prototype[method] = function (element) {
|
|
855
|
+
let data;
|
|
856
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
857
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
858
|
+
if (arguments.length > 1) {
|
|
859
|
+
if (this.multi)
|
|
860
|
+
throw new UsageGraphError(
|
|
861
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
862
|
+
);
|
|
863
|
+
const source = "" + element,
|
|
864
|
+
target = "" + arguments[1];
|
|
865
|
+
data = getMatchingEdge(this, source, target, type);
|
|
866
|
+
if (!data)
|
|
867
|
+
throw new NotFoundGraphError(
|
|
868
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
869
|
+
);
|
|
870
|
+
} else {
|
|
871
|
+
if (type !== "mixed")
|
|
872
|
+
throw new UsageGraphError(
|
|
873
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
874
|
+
);
|
|
875
|
+
element = "" + element;
|
|
876
|
+
data = this._edges.get(element);
|
|
877
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
878
|
+
}
|
|
879
|
+
return data.attributes;
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
function attachEdgeAttributeChecker(Class, method, type) {
|
|
883
|
+
Class.prototype[method] = function (element, name) {
|
|
884
|
+
let data;
|
|
885
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
886
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
887
|
+
if (arguments.length > 2) {
|
|
888
|
+
if (this.multi)
|
|
889
|
+
throw new UsageGraphError(
|
|
890
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
891
|
+
);
|
|
892
|
+
const source = "" + element;
|
|
893
|
+
const target = "" + name;
|
|
894
|
+
name = arguments[2];
|
|
895
|
+
data = getMatchingEdge(this, source, target, type);
|
|
896
|
+
if (!data)
|
|
897
|
+
throw new NotFoundGraphError(
|
|
898
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
899
|
+
);
|
|
900
|
+
} else {
|
|
901
|
+
if (type !== "mixed")
|
|
902
|
+
throw new UsageGraphError(
|
|
903
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
904
|
+
);
|
|
905
|
+
element = "" + element;
|
|
906
|
+
data = this._edges.get(element);
|
|
907
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
908
|
+
}
|
|
909
|
+
return data.attributes.hasOwnProperty(name);
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function attachEdgeAttributeSetter(Class, method, type) {
|
|
913
|
+
Class.prototype[method] = function (element, name, value) {
|
|
914
|
+
let data;
|
|
915
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
916
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
917
|
+
if (arguments.length > 3) {
|
|
918
|
+
if (this.multi)
|
|
919
|
+
throw new UsageGraphError(
|
|
920
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
921
|
+
);
|
|
922
|
+
const source = "" + element;
|
|
923
|
+
const target = "" + name;
|
|
924
|
+
name = arguments[2];
|
|
925
|
+
value = arguments[3];
|
|
926
|
+
data = getMatchingEdge(this, source, target, type);
|
|
927
|
+
if (!data)
|
|
928
|
+
throw new NotFoundGraphError(
|
|
929
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
930
|
+
);
|
|
931
|
+
} else {
|
|
932
|
+
if (type !== "mixed")
|
|
933
|
+
throw new UsageGraphError(
|
|
934
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
935
|
+
);
|
|
936
|
+
element = "" + element;
|
|
937
|
+
data = this._edges.get(element);
|
|
938
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
939
|
+
}
|
|
940
|
+
data.attributes[name] = value;
|
|
941
|
+
this.emit("edgeAttributesUpdated", {
|
|
942
|
+
key: data.key,
|
|
943
|
+
type: "set",
|
|
944
|
+
attributes: data.attributes,
|
|
945
|
+
name,
|
|
946
|
+
});
|
|
947
|
+
return this;
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
function attachEdgeAttributeUpdater(Class, method, type) {
|
|
951
|
+
Class.prototype[method] = function (element, name, updater) {
|
|
952
|
+
let data;
|
|
953
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
954
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
955
|
+
if (arguments.length > 3) {
|
|
956
|
+
if (this.multi)
|
|
957
|
+
throw new UsageGraphError(
|
|
958
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
959
|
+
);
|
|
960
|
+
const source = "" + element;
|
|
961
|
+
const target = "" + name;
|
|
962
|
+
name = arguments[2];
|
|
963
|
+
updater = arguments[3];
|
|
964
|
+
data = getMatchingEdge(this, source, target, type);
|
|
965
|
+
if (!data)
|
|
966
|
+
throw new NotFoundGraphError(
|
|
967
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
968
|
+
);
|
|
969
|
+
} else {
|
|
970
|
+
if (type !== "mixed")
|
|
971
|
+
throw new UsageGraphError(
|
|
972
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
973
|
+
);
|
|
974
|
+
element = "" + element;
|
|
975
|
+
data = this._edges.get(element);
|
|
976
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
977
|
+
}
|
|
978
|
+
if (typeof updater !== "function")
|
|
979
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: updater should be a function.`);
|
|
980
|
+
data.attributes[name] = updater(data.attributes[name]);
|
|
981
|
+
this.emit("edgeAttributesUpdated", {
|
|
982
|
+
key: data.key,
|
|
983
|
+
type: "set",
|
|
984
|
+
attributes: data.attributes,
|
|
985
|
+
name,
|
|
986
|
+
});
|
|
987
|
+
return this;
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function attachEdgeAttributeRemover(Class, method, type) {
|
|
991
|
+
Class.prototype[method] = function (element, name) {
|
|
992
|
+
let data;
|
|
993
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
994
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
995
|
+
if (arguments.length > 2) {
|
|
996
|
+
if (this.multi)
|
|
997
|
+
throw new UsageGraphError(
|
|
998
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
999
|
+
);
|
|
1000
|
+
const source = "" + element;
|
|
1001
|
+
const target = "" + name;
|
|
1002
|
+
name = arguments[2];
|
|
1003
|
+
data = getMatchingEdge(this, source, target, type);
|
|
1004
|
+
if (!data)
|
|
1005
|
+
throw new NotFoundGraphError(
|
|
1006
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
1007
|
+
);
|
|
1008
|
+
} else {
|
|
1009
|
+
if (type !== "mixed")
|
|
1010
|
+
throw new UsageGraphError(
|
|
1011
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
1012
|
+
);
|
|
1013
|
+
element = "" + element;
|
|
1014
|
+
data = this._edges.get(element);
|
|
1015
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
1016
|
+
}
|
|
1017
|
+
delete data.attributes[name];
|
|
1018
|
+
this.emit("edgeAttributesUpdated", {
|
|
1019
|
+
key: data.key,
|
|
1020
|
+
type: "remove",
|
|
1021
|
+
attributes: data.attributes,
|
|
1022
|
+
name,
|
|
1023
|
+
});
|
|
1024
|
+
return this;
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function attachEdgeAttributesReplacer(Class, method, type) {
|
|
1028
|
+
Class.prototype[method] = function (element, attributes) {
|
|
1029
|
+
let data;
|
|
1030
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
1031
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
1032
|
+
if (arguments.length > 2) {
|
|
1033
|
+
if (this.multi)
|
|
1034
|
+
throw new UsageGraphError(
|
|
1035
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
1036
|
+
);
|
|
1037
|
+
const source = "" + element,
|
|
1038
|
+
target = "" + attributes;
|
|
1039
|
+
attributes = arguments[2];
|
|
1040
|
+
data = getMatchingEdge(this, source, target, type);
|
|
1041
|
+
if (!data)
|
|
1042
|
+
throw new NotFoundGraphError(
|
|
1043
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
1044
|
+
);
|
|
1045
|
+
} else {
|
|
1046
|
+
if (type !== "mixed")
|
|
1047
|
+
throw new UsageGraphError(
|
|
1048
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
1049
|
+
);
|
|
1050
|
+
element = "" + element;
|
|
1051
|
+
data = this._edges.get(element);
|
|
1052
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
1053
|
+
}
|
|
1054
|
+
if (!isPlainObject(attributes))
|
|
1055
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided attributes are not a plain object.`);
|
|
1056
|
+
data.attributes = attributes;
|
|
1057
|
+
this.emit("edgeAttributesUpdated", {
|
|
1058
|
+
key: data.key,
|
|
1059
|
+
type: "replace",
|
|
1060
|
+
attributes: data.attributes,
|
|
1061
|
+
});
|
|
1062
|
+
return this;
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function attachEdgeAttributesMerger(Class, method, type) {
|
|
1066
|
+
Class.prototype[method] = function (element, attributes) {
|
|
1067
|
+
let data;
|
|
1068
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
1069
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
1070
|
+
if (arguments.length > 2) {
|
|
1071
|
+
if (this.multi)
|
|
1072
|
+
throw new UsageGraphError(
|
|
1073
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
1074
|
+
);
|
|
1075
|
+
const source = "" + element,
|
|
1076
|
+
target = "" + attributes;
|
|
1077
|
+
attributes = arguments[2];
|
|
1078
|
+
data = getMatchingEdge(this, source, target, type);
|
|
1079
|
+
if (!data)
|
|
1080
|
+
throw new NotFoundGraphError(
|
|
1081
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
1082
|
+
);
|
|
1083
|
+
} else {
|
|
1084
|
+
if (type !== "mixed")
|
|
1085
|
+
throw new UsageGraphError(
|
|
1086
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
1087
|
+
);
|
|
1088
|
+
element = "" + element;
|
|
1089
|
+
data = this._edges.get(element);
|
|
1090
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
1091
|
+
}
|
|
1092
|
+
if (!isPlainObject(attributes))
|
|
1093
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided attributes are not a plain object.`);
|
|
1094
|
+
assign(data.attributes, attributes);
|
|
1095
|
+
this.emit("edgeAttributesUpdated", {
|
|
1096
|
+
key: data.key,
|
|
1097
|
+
type: "merge",
|
|
1098
|
+
attributes: data.attributes,
|
|
1099
|
+
data: attributes,
|
|
1100
|
+
});
|
|
1101
|
+
return this;
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
function attachEdgeAttributesUpdater(Class, method, type) {
|
|
1105
|
+
Class.prototype[method] = function (element, updater) {
|
|
1106
|
+
let data;
|
|
1107
|
+
if (this.type !== "mixed" && type !== "mixed" && type !== this.type)
|
|
1108
|
+
throw new UsageGraphError(`Graph.${method}: cannot find this type of edges in your ${this.type} graph.`);
|
|
1109
|
+
if (arguments.length > 2) {
|
|
1110
|
+
if (this.multi)
|
|
1111
|
+
throw new UsageGraphError(
|
|
1112
|
+
`Graph.${method}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`,
|
|
1113
|
+
);
|
|
1114
|
+
const source = "" + element,
|
|
1115
|
+
target = "" + updater;
|
|
1116
|
+
updater = arguments[2];
|
|
1117
|
+
data = getMatchingEdge(this, source, target, type);
|
|
1118
|
+
if (!data)
|
|
1119
|
+
throw new NotFoundGraphError(
|
|
1120
|
+
`Graph.${method}: could not find an edge for the given path ("${source}" - "${target}").`,
|
|
1121
|
+
);
|
|
1122
|
+
} else {
|
|
1123
|
+
if (type !== "mixed")
|
|
1124
|
+
throw new UsageGraphError(
|
|
1125
|
+
`Graph.${method}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`,
|
|
1126
|
+
);
|
|
1127
|
+
element = "" + element;
|
|
1128
|
+
data = this._edges.get(element);
|
|
1129
|
+
if (!data) throw new NotFoundGraphError(`Graph.${method}: could not find the "${element}" edge in the graph.`);
|
|
1130
|
+
}
|
|
1131
|
+
if (typeof updater !== "function")
|
|
1132
|
+
throw new InvalidArgumentsGraphError(`Graph.${method}: provided updater is not a function.`);
|
|
1133
|
+
data.attributes = updater(data.attributes);
|
|
1134
|
+
this.emit("edgeAttributesUpdated", {
|
|
1135
|
+
key: data.key,
|
|
1136
|
+
type: "update",
|
|
1137
|
+
attributes: data.attributes,
|
|
1138
|
+
});
|
|
1139
|
+
return this;
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
var EDGE_ATTRIBUTES_METHODS = [
|
|
1143
|
+
{
|
|
1144
|
+
name: (element) => `get${element}Attribute`,
|
|
1145
|
+
attacher: attachEdgeAttributeGetter,
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
name: (element) => `get${element}Attributes`,
|
|
1149
|
+
attacher: attachEdgeAttributesGetter,
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: (element) => `has${element}Attribute`,
|
|
1153
|
+
attacher: attachEdgeAttributeChecker,
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
name: (element) => `set${element}Attribute`,
|
|
1157
|
+
attacher: attachEdgeAttributeSetter,
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: (element) => `update${element}Attribute`,
|
|
1161
|
+
attacher: attachEdgeAttributeUpdater,
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
name: (element) => `remove${element}Attribute`,
|
|
1165
|
+
attacher: attachEdgeAttributeRemover,
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
name: (element) => `replace${element}Attributes`,
|
|
1169
|
+
attacher: attachEdgeAttributesReplacer,
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
name: (element) => `merge${element}Attributes`,
|
|
1173
|
+
attacher: attachEdgeAttributesMerger,
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
name: (element) => `update${element}Attributes`,
|
|
1177
|
+
attacher: attachEdgeAttributesUpdater,
|
|
1178
|
+
},
|
|
1179
|
+
];
|
|
1180
|
+
function attachEdgeAttributesMethods(Graph2) {
|
|
1181
|
+
EDGE_ATTRIBUTES_METHODS.forEach(function ({ name, attacher }) {
|
|
1182
|
+
attacher(Graph2, name("Edge"), "mixed");
|
|
1183
|
+
attacher(Graph2, name("DirectedEdge"), "directed");
|
|
1184
|
+
attacher(Graph2, name("UndirectedEdge"), "undirected");
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
var EDGES_ITERATION = [
|
|
1188
|
+
{
|
|
1189
|
+
name: "edges",
|
|
1190
|
+
type: "mixed",
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
name: "inEdges",
|
|
1194
|
+
type: "directed",
|
|
1195
|
+
direction: "in",
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
name: "outEdges",
|
|
1199
|
+
type: "directed",
|
|
1200
|
+
direction: "out",
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: "inboundEdges",
|
|
1204
|
+
type: "mixed",
|
|
1205
|
+
direction: "in",
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: "outboundEdges",
|
|
1209
|
+
type: "mixed",
|
|
1210
|
+
direction: "out",
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
name: "directedEdges",
|
|
1214
|
+
type: "directed",
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "undirectedEdges",
|
|
1218
|
+
type: "undirected",
|
|
1219
|
+
},
|
|
1220
|
+
];
|
|
1221
|
+
function forEachSimple(breakable, object, callback, avoid) {
|
|
1222
|
+
let shouldBreak = false;
|
|
1223
|
+
for (const k in object) {
|
|
1224
|
+
if (k === avoid) continue;
|
|
1225
|
+
const edgeData = object[k];
|
|
1226
|
+
shouldBreak = callback(
|
|
1227
|
+
edgeData.key,
|
|
1228
|
+
edgeData.attributes,
|
|
1229
|
+
edgeData.source.key,
|
|
1230
|
+
edgeData.target.key,
|
|
1231
|
+
edgeData.source.attributes,
|
|
1232
|
+
edgeData.target.attributes,
|
|
1233
|
+
edgeData.undirected,
|
|
1234
|
+
);
|
|
1235
|
+
if (breakable && shouldBreak) return edgeData.key;
|
|
1236
|
+
}
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
function forEachMulti(breakable, object, callback, avoid) {
|
|
1240
|
+
let edgeData, source, target;
|
|
1241
|
+
let shouldBreak = false;
|
|
1242
|
+
for (const k in object) {
|
|
1243
|
+
if (k === avoid) continue;
|
|
1244
|
+
edgeData = object[k];
|
|
1245
|
+
do {
|
|
1246
|
+
source = edgeData.source;
|
|
1247
|
+
target = edgeData.target;
|
|
1248
|
+
shouldBreak = callback(
|
|
1249
|
+
edgeData.key,
|
|
1250
|
+
edgeData.attributes,
|
|
1251
|
+
source.key,
|
|
1252
|
+
target.key,
|
|
1253
|
+
source.attributes,
|
|
1254
|
+
target.attributes,
|
|
1255
|
+
edgeData.undirected,
|
|
1256
|
+
);
|
|
1257
|
+
if (breakable && shouldBreak) return edgeData.key;
|
|
1258
|
+
edgeData = edgeData.next;
|
|
1259
|
+
} while (edgeData !== void 0);
|
|
1260
|
+
}
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
function createIterator(object, avoid) {
|
|
1264
|
+
const keys = Object.keys(object);
|
|
1265
|
+
const l = keys.length;
|
|
1266
|
+
let edgeData;
|
|
1267
|
+
let i = 0;
|
|
1268
|
+
return {
|
|
1269
|
+
[Symbol.iterator]() {
|
|
1270
|
+
return this;
|
|
1271
|
+
},
|
|
1272
|
+
next() {
|
|
1273
|
+
do {
|
|
1274
|
+
if (!edgeData) {
|
|
1275
|
+
if (i >= l) return { done: true };
|
|
1276
|
+
const k = keys[i++];
|
|
1277
|
+
if (k === avoid) {
|
|
1278
|
+
edgeData = void 0;
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
edgeData = object[k];
|
|
1282
|
+
} else {
|
|
1283
|
+
edgeData = edgeData.next;
|
|
1284
|
+
}
|
|
1285
|
+
} while (!edgeData);
|
|
1286
|
+
return {
|
|
1287
|
+
done: false,
|
|
1288
|
+
value: {
|
|
1289
|
+
edge: edgeData.key,
|
|
1290
|
+
attributes: edgeData.attributes,
|
|
1291
|
+
source: edgeData.source.key,
|
|
1292
|
+
target: edgeData.target.key,
|
|
1293
|
+
sourceAttributes: edgeData.source.attributes,
|
|
1294
|
+
targetAttributes: edgeData.target.attributes,
|
|
1295
|
+
undirected: edgeData.undirected,
|
|
1296
|
+
},
|
|
1297
|
+
};
|
|
1298
|
+
},
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
function forEachForKeySimple(breakable, object, k, callback) {
|
|
1302
|
+
const edgeData = object[k];
|
|
1303
|
+
if (!edgeData) return;
|
|
1304
|
+
const sourceData = edgeData.source;
|
|
1305
|
+
const targetData = edgeData.target;
|
|
1306
|
+
if (
|
|
1307
|
+
callback(
|
|
1308
|
+
edgeData.key,
|
|
1309
|
+
edgeData.attributes,
|
|
1310
|
+
sourceData.key,
|
|
1311
|
+
targetData.key,
|
|
1312
|
+
sourceData.attributes,
|
|
1313
|
+
targetData.attributes,
|
|
1314
|
+
edgeData.undirected,
|
|
1315
|
+
) &&
|
|
1316
|
+
breakable
|
|
1317
|
+
)
|
|
1318
|
+
return edgeData.key;
|
|
1319
|
+
}
|
|
1320
|
+
function forEachForKeyMulti(breakable, object, k, callback) {
|
|
1321
|
+
let edgeData = object[k];
|
|
1322
|
+
if (!edgeData) return;
|
|
1323
|
+
let shouldBreak = false;
|
|
1324
|
+
do {
|
|
1325
|
+
shouldBreak = callback(
|
|
1326
|
+
edgeData.key,
|
|
1327
|
+
edgeData.attributes,
|
|
1328
|
+
edgeData.source.key,
|
|
1329
|
+
edgeData.target.key,
|
|
1330
|
+
edgeData.source.attributes,
|
|
1331
|
+
edgeData.target.attributes,
|
|
1332
|
+
edgeData.undirected,
|
|
1333
|
+
);
|
|
1334
|
+
if (breakable && shouldBreak) return edgeData.key;
|
|
1335
|
+
edgeData = edgeData.next;
|
|
1336
|
+
} while (edgeData !== void 0);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
function createIteratorForKey(object, k) {
|
|
1340
|
+
let edgeData = object[k];
|
|
1341
|
+
if (edgeData.next !== void 0) {
|
|
1342
|
+
return {
|
|
1343
|
+
[Symbol.iterator]() {
|
|
1344
|
+
return this;
|
|
1345
|
+
},
|
|
1346
|
+
next() {
|
|
1347
|
+
if (!edgeData) return { done: true };
|
|
1348
|
+
const value = {
|
|
1349
|
+
edge: edgeData.key,
|
|
1350
|
+
attributes: edgeData.attributes,
|
|
1351
|
+
source: edgeData.source.key,
|
|
1352
|
+
target: edgeData.target.key,
|
|
1353
|
+
sourceAttributes: edgeData.source.attributes,
|
|
1354
|
+
targetAttributes: edgeData.target.attributes,
|
|
1355
|
+
undirected: edgeData.undirected,
|
|
1356
|
+
};
|
|
1357
|
+
edgeData = edgeData.next;
|
|
1358
|
+
return {
|
|
1359
|
+
done: false,
|
|
1360
|
+
value,
|
|
1361
|
+
};
|
|
1362
|
+
},
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
let done = false;
|
|
1366
|
+
return {
|
|
1367
|
+
[Symbol.iterator]() {
|
|
1368
|
+
return this;
|
|
1369
|
+
},
|
|
1370
|
+
next() {
|
|
1371
|
+
if (done === true) return { done: true };
|
|
1372
|
+
done = true;
|
|
1373
|
+
return {
|
|
1374
|
+
done: false,
|
|
1375
|
+
value: {
|
|
1376
|
+
edge: edgeData.key,
|
|
1377
|
+
attributes: edgeData.attributes,
|
|
1378
|
+
source: edgeData.source.key,
|
|
1379
|
+
target: edgeData.target.key,
|
|
1380
|
+
sourceAttributes: edgeData.source.attributes,
|
|
1381
|
+
targetAttributes: edgeData.target.attributes,
|
|
1382
|
+
undirected: edgeData.undirected,
|
|
1383
|
+
},
|
|
1384
|
+
};
|
|
1385
|
+
},
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
function createEdgeArray(graph, type) {
|
|
1389
|
+
if (graph.size === 0) return [];
|
|
1390
|
+
if (type === "mixed" || type === graph.type) {
|
|
1391
|
+
return Array.from(graph._edges.keys());
|
|
1392
|
+
}
|
|
1393
|
+
const size = type === "undirected" ? graph.undirectedSize : graph.directedSize;
|
|
1394
|
+
const list = new Array(size),
|
|
1395
|
+
mask = type === "undirected";
|
|
1396
|
+
const iterator = graph._edges.values();
|
|
1397
|
+
let i = 0;
|
|
1398
|
+
let step, data;
|
|
1399
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
1400
|
+
data = step.value;
|
|
1401
|
+
if (data.undirected === mask) list[i++] = data.key;
|
|
1402
|
+
}
|
|
1403
|
+
return list;
|
|
1404
|
+
}
|
|
1405
|
+
function forEachEdge(breakable, graph, type, callback) {
|
|
1406
|
+
if (graph.size === 0) return;
|
|
1407
|
+
const shouldFilter = type !== "mixed" && type !== graph.type;
|
|
1408
|
+
const mask = type === "undirected";
|
|
1409
|
+
let step, data;
|
|
1410
|
+
let shouldBreak = false;
|
|
1411
|
+
const iterator = graph._edges.values();
|
|
1412
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
1413
|
+
data = step.value;
|
|
1414
|
+
if (shouldFilter && data.undirected !== mask) continue;
|
|
1415
|
+
const { key, attributes, source, target } = data;
|
|
1416
|
+
shouldBreak = callback(
|
|
1417
|
+
key,
|
|
1418
|
+
attributes,
|
|
1419
|
+
source.key,
|
|
1420
|
+
target.key,
|
|
1421
|
+
source.attributes,
|
|
1422
|
+
target.attributes,
|
|
1423
|
+
data.undirected,
|
|
1424
|
+
);
|
|
1425
|
+
if (breakable && shouldBreak) return key;
|
|
1426
|
+
}
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
function createEdgeIterator(graph, type) {
|
|
1430
|
+
if (graph.size === 0) return emptyIterator();
|
|
1431
|
+
const shouldFilter = type !== "mixed" && type !== graph.type;
|
|
1432
|
+
const mask = type === "undirected";
|
|
1433
|
+
const iterator = graph._edges.values();
|
|
1434
|
+
return {
|
|
1435
|
+
[Symbol.iterator]() {
|
|
1436
|
+
return this;
|
|
1437
|
+
},
|
|
1438
|
+
next() {
|
|
1439
|
+
let step, data;
|
|
1440
|
+
while (true) {
|
|
1441
|
+
step = iterator.next();
|
|
1442
|
+
if (step.done) return step;
|
|
1443
|
+
data = step.value;
|
|
1444
|
+
if (shouldFilter && data.undirected !== mask) continue;
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
const value = {
|
|
1448
|
+
edge: data.key,
|
|
1449
|
+
attributes: data.attributes,
|
|
1450
|
+
source: data.source.key,
|
|
1451
|
+
target: data.target.key,
|
|
1452
|
+
sourceAttributes: data.source.attributes,
|
|
1453
|
+
targetAttributes: data.target.attributes,
|
|
1454
|
+
undirected: data.undirected,
|
|
1455
|
+
};
|
|
1456
|
+
return { value, done: false };
|
|
1457
|
+
},
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
function forEachEdgeForNode(breakable, multi, type, direction, nodeData, callback) {
|
|
1461
|
+
const fn = multi ? forEachMulti : forEachSimple;
|
|
1462
|
+
let found;
|
|
1463
|
+
if (type !== "undirected") {
|
|
1464
|
+
if (direction !== "out") {
|
|
1465
|
+
found = fn(breakable, nodeData.in, callback);
|
|
1466
|
+
if (breakable && found) return found;
|
|
1467
|
+
}
|
|
1468
|
+
if (direction !== "in") {
|
|
1469
|
+
found = fn(breakable, nodeData.out, callback, !direction ? nodeData.key : void 0);
|
|
1470
|
+
if (breakable && found) return found;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if (type !== "directed") {
|
|
1474
|
+
found = fn(breakable, nodeData.undirected, callback);
|
|
1475
|
+
if (breakable && found) return found;
|
|
1476
|
+
}
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
function createEdgeArrayForNode(multi, type, direction, nodeData) {
|
|
1480
|
+
const edges = [];
|
|
1481
|
+
forEachEdgeForNode(false, multi, type, direction, nodeData, function (key) {
|
|
1482
|
+
edges.push(key);
|
|
1483
|
+
});
|
|
1484
|
+
return edges;
|
|
1485
|
+
}
|
|
1486
|
+
function createEdgeIteratorForNode(type, direction, nodeData) {
|
|
1487
|
+
let iterator = emptyIterator();
|
|
1488
|
+
if (type !== "undirected") {
|
|
1489
|
+
if (direction !== "out" && typeof nodeData.in !== "undefined")
|
|
1490
|
+
iterator = chain(iterator, createIterator(nodeData.in));
|
|
1491
|
+
if (direction !== "in" && typeof nodeData.out !== "undefined")
|
|
1492
|
+
iterator = chain(iterator, createIterator(nodeData.out, !direction ? nodeData.key : void 0));
|
|
1493
|
+
}
|
|
1494
|
+
if (type !== "directed" && typeof nodeData.undirected !== "undefined") {
|
|
1495
|
+
iterator = chain(iterator, createIterator(nodeData.undirected));
|
|
1496
|
+
}
|
|
1497
|
+
return iterator;
|
|
1498
|
+
}
|
|
1499
|
+
function forEachEdgeForPath(breakable, type, multi, direction, sourceData, target, callback) {
|
|
1500
|
+
const fn = multi ? forEachForKeyMulti : forEachForKeySimple;
|
|
1501
|
+
let found;
|
|
1502
|
+
if (type !== "undirected") {
|
|
1503
|
+
if (typeof sourceData.in !== "undefined" && direction !== "out") {
|
|
1504
|
+
found = fn(breakable, sourceData.in, target, callback);
|
|
1505
|
+
if (breakable && found) return found;
|
|
1506
|
+
}
|
|
1507
|
+
if (typeof sourceData.out !== "undefined" && direction !== "in" && (direction || sourceData.key !== target)) {
|
|
1508
|
+
found = fn(breakable, sourceData.out, target, callback);
|
|
1509
|
+
if (breakable && found) return found;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
if (type !== "directed") {
|
|
1513
|
+
if (typeof sourceData.undirected !== "undefined") {
|
|
1514
|
+
found = fn(breakable, sourceData.undirected, target, callback);
|
|
1515
|
+
if (breakable && found) return found;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
function createEdgeArrayForPath(type, multi, direction, sourceData, target) {
|
|
1521
|
+
const edges = [];
|
|
1522
|
+
forEachEdgeForPath(false, type, multi, direction, sourceData, target, function (key) {
|
|
1523
|
+
edges.push(key);
|
|
1524
|
+
});
|
|
1525
|
+
return edges;
|
|
1526
|
+
}
|
|
1527
|
+
function createEdgeIteratorForPath(type, direction, sourceData, target) {
|
|
1528
|
+
let iterator = emptyIterator();
|
|
1529
|
+
if (type !== "undirected") {
|
|
1530
|
+
if (typeof sourceData.in !== "undefined" && direction !== "out" && target in sourceData.in)
|
|
1531
|
+
iterator = chain(iterator, createIteratorForKey(sourceData.in, target));
|
|
1532
|
+
if (
|
|
1533
|
+
typeof sourceData.out !== "undefined" &&
|
|
1534
|
+
direction !== "in" &&
|
|
1535
|
+
target in sourceData.out &&
|
|
1536
|
+
(direction || sourceData.key !== target)
|
|
1537
|
+
)
|
|
1538
|
+
iterator = chain(iterator, createIteratorForKey(sourceData.out, target));
|
|
1539
|
+
}
|
|
1540
|
+
if (type !== "directed") {
|
|
1541
|
+
if (typeof sourceData.undirected !== "undefined" && target in sourceData.undirected)
|
|
1542
|
+
iterator = chain(iterator, createIteratorForKey(sourceData.undirected, target));
|
|
1543
|
+
}
|
|
1544
|
+
return iterator;
|
|
1545
|
+
}
|
|
1546
|
+
function attachEdgeArrayCreator(Class, description) {
|
|
1547
|
+
const { name, type, direction } = description;
|
|
1548
|
+
Class.prototype[name] = function (source, target) {
|
|
1549
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return [];
|
|
1550
|
+
if (!arguments.length) return createEdgeArray(this, type);
|
|
1551
|
+
if (arguments.length === 1) {
|
|
1552
|
+
source = "" + source;
|
|
1553
|
+
const nodeData = this._nodes.get(source);
|
|
1554
|
+
if (typeof nodeData === "undefined")
|
|
1555
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${source}" node in the graph.`);
|
|
1556
|
+
return createEdgeArrayForNode(this.multi, type === "mixed" ? this.type : type, direction, nodeData);
|
|
1557
|
+
}
|
|
1558
|
+
if (arguments.length === 2) {
|
|
1559
|
+
source = "" + source;
|
|
1560
|
+
target = "" + target;
|
|
1561
|
+
const sourceData = this._nodes.get(source);
|
|
1562
|
+
if (!sourceData)
|
|
1563
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${source}" source node in the graph.`);
|
|
1564
|
+
if (!this._nodes.has(target))
|
|
1565
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${target}" target node in the graph.`);
|
|
1566
|
+
return createEdgeArrayForPath(type, this.multi, direction, sourceData, target);
|
|
1567
|
+
}
|
|
1568
|
+
throw new InvalidArgumentsGraphError(
|
|
1569
|
+
`Graph.${name}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`,
|
|
1570
|
+
);
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
function attachForEachEdge(Class, description) {
|
|
1574
|
+
const { name, type, direction } = description;
|
|
1575
|
+
const forEachName = "forEach" + name[0].toUpperCase() + name.slice(1, -1);
|
|
1576
|
+
Class.prototype[forEachName] = function (source, target, callback) {
|
|
1577
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return;
|
|
1578
|
+
if (arguments.length === 1) {
|
|
1579
|
+
callback = source;
|
|
1580
|
+
return forEachEdge(false, this, type, callback);
|
|
1581
|
+
}
|
|
1582
|
+
if (arguments.length === 2) {
|
|
1583
|
+
source = "" + source;
|
|
1584
|
+
callback = target;
|
|
1585
|
+
const nodeData = this._nodes.get(source);
|
|
1586
|
+
if (typeof nodeData === "undefined")
|
|
1587
|
+
throw new NotFoundGraphError(`Graph.${forEachName}: could not find the "${source}" node in the graph.`);
|
|
1588
|
+
return forEachEdgeForNode(false, this.multi, type === "mixed" ? this.type : type, direction, nodeData, callback);
|
|
1589
|
+
}
|
|
1590
|
+
if (arguments.length === 3) {
|
|
1591
|
+
source = "" + source;
|
|
1592
|
+
target = "" + target;
|
|
1593
|
+
const sourceData = this._nodes.get(source);
|
|
1594
|
+
if (!sourceData)
|
|
1595
|
+
throw new NotFoundGraphError(`Graph.${forEachName}: could not find the "${source}" source node in the graph.`);
|
|
1596
|
+
if (!this._nodes.has(target))
|
|
1597
|
+
throw new NotFoundGraphError(`Graph.${forEachName}: could not find the "${target}" target node in the graph.`);
|
|
1598
|
+
return forEachEdgeForPath(false, type, this.multi, direction, sourceData, target, callback);
|
|
1599
|
+
}
|
|
1600
|
+
throw new InvalidArgumentsGraphError(
|
|
1601
|
+
`Graph.${forEachName}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`,
|
|
1602
|
+
);
|
|
1603
|
+
};
|
|
1604
|
+
const mapName = "map" + name[0].toUpperCase() + name.slice(1);
|
|
1605
|
+
Class.prototype[mapName] = function () {
|
|
1606
|
+
const args = Array.prototype.slice.call(arguments);
|
|
1607
|
+
const callback = args.pop();
|
|
1608
|
+
let result;
|
|
1609
|
+
if (args.length === 0) {
|
|
1610
|
+
let length = 0;
|
|
1611
|
+
if (type !== "directed") length += this.undirectedSize;
|
|
1612
|
+
if (type !== "undirected") length += this.directedSize;
|
|
1613
|
+
result = new Array(length);
|
|
1614
|
+
let i = 0;
|
|
1615
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1616
|
+
result[i++] = callback(e, ea, s, t, sa, ta, u);
|
|
1617
|
+
});
|
|
1618
|
+
} else {
|
|
1619
|
+
result = [];
|
|
1620
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1621
|
+
result.push(callback(e, ea, s, t, sa, ta, u));
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
this[forEachName].apply(this, args);
|
|
1625
|
+
return result;
|
|
1626
|
+
};
|
|
1627
|
+
const filterName = "filter" + name[0].toUpperCase() + name.slice(1);
|
|
1628
|
+
Class.prototype[filterName] = function () {
|
|
1629
|
+
const args = Array.prototype.slice.call(arguments);
|
|
1630
|
+
const callback = args.pop();
|
|
1631
|
+
const result = [];
|
|
1632
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1633
|
+
if (callback(e, ea, s, t, sa, ta, u)) result.push(e);
|
|
1634
|
+
});
|
|
1635
|
+
this[forEachName].apply(this, args);
|
|
1636
|
+
return result;
|
|
1637
|
+
};
|
|
1638
|
+
const reduceName = "reduce" + name[0].toUpperCase() + name.slice(1);
|
|
1639
|
+
Class.prototype[reduceName] = function () {
|
|
1640
|
+
let args = Array.prototype.slice.call(arguments);
|
|
1641
|
+
if (args.length < 2 || args.length > 4) {
|
|
1642
|
+
throw new InvalidArgumentsGraphError(
|
|
1643
|
+
`Graph.${reduceName}: invalid number of arguments (expecting 2, 3 or 4 and got ${args.length}).`,
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1646
|
+
if (typeof args[args.length - 1] === "function" && typeof args[args.length - 2] !== "function") {
|
|
1647
|
+
throw new InvalidArgumentsGraphError(
|
|
1648
|
+
`Graph.${reduceName}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`,
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
let callback;
|
|
1652
|
+
let initialValue;
|
|
1653
|
+
if (args.length === 2) {
|
|
1654
|
+
callback = args[0];
|
|
1655
|
+
initialValue = args[1];
|
|
1656
|
+
args = [];
|
|
1657
|
+
} else if (args.length === 3) {
|
|
1658
|
+
callback = args[1];
|
|
1659
|
+
initialValue = args[2];
|
|
1660
|
+
args = [args[0]];
|
|
1661
|
+
} else if (args.length === 4) {
|
|
1662
|
+
callback = args[2];
|
|
1663
|
+
initialValue = args[3];
|
|
1664
|
+
args = [args[0], args[1]];
|
|
1665
|
+
}
|
|
1666
|
+
let accumulator = initialValue;
|
|
1667
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1668
|
+
accumulator = callback(accumulator, e, ea, s, t, sa, ta, u);
|
|
1669
|
+
});
|
|
1670
|
+
this[forEachName].apply(this, args);
|
|
1671
|
+
return accumulator;
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
function attachFindEdge(Class, description) {
|
|
1675
|
+
const { name, type, direction } = description;
|
|
1676
|
+
const findEdgeName = "find" + name[0].toUpperCase() + name.slice(1, -1);
|
|
1677
|
+
Class.prototype[findEdgeName] = function (source, target, callback) {
|
|
1678
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return false;
|
|
1679
|
+
if (arguments.length === 1) {
|
|
1680
|
+
callback = source;
|
|
1681
|
+
return forEachEdge(true, this, type, callback);
|
|
1682
|
+
}
|
|
1683
|
+
if (arguments.length === 2) {
|
|
1684
|
+
source = "" + source;
|
|
1685
|
+
callback = target;
|
|
1686
|
+
const nodeData = this._nodes.get(source);
|
|
1687
|
+
if (typeof nodeData === "undefined")
|
|
1688
|
+
throw new NotFoundGraphError(`Graph.${findEdgeName}: could not find the "${source}" node in the graph.`);
|
|
1689
|
+
return forEachEdgeForNode(true, this.multi, type === "mixed" ? this.type : type, direction, nodeData, callback);
|
|
1690
|
+
}
|
|
1691
|
+
if (arguments.length === 3) {
|
|
1692
|
+
source = "" + source;
|
|
1693
|
+
target = "" + target;
|
|
1694
|
+
const sourceData = this._nodes.get(source);
|
|
1695
|
+
if (!sourceData)
|
|
1696
|
+
throw new NotFoundGraphError(
|
|
1697
|
+
`Graph.${findEdgeName}: could not find the "${source}" source node in the graph.`,
|
|
1698
|
+
);
|
|
1699
|
+
if (!this._nodes.has(target))
|
|
1700
|
+
throw new NotFoundGraphError(
|
|
1701
|
+
`Graph.${findEdgeName}: could not find the "${target}" target node in the graph.`,
|
|
1702
|
+
);
|
|
1703
|
+
return forEachEdgeForPath(true, type, this.multi, direction, sourceData, target, callback);
|
|
1704
|
+
}
|
|
1705
|
+
throw new InvalidArgumentsGraphError(
|
|
1706
|
+
`Graph.${findEdgeName}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`,
|
|
1707
|
+
);
|
|
1708
|
+
};
|
|
1709
|
+
const someName = "some" + name[0].toUpperCase() + name.slice(1, -1);
|
|
1710
|
+
Class.prototype[someName] = function () {
|
|
1711
|
+
const args = Array.prototype.slice.call(arguments);
|
|
1712
|
+
const callback = args.pop();
|
|
1713
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1714
|
+
return callback(e, ea, s, t, sa, ta, u);
|
|
1715
|
+
});
|
|
1716
|
+
const found = this[findEdgeName].apply(this, args);
|
|
1717
|
+
if (found) return true;
|
|
1718
|
+
return false;
|
|
1719
|
+
};
|
|
1720
|
+
const everyName = "every" + name[0].toUpperCase() + name.slice(1, -1);
|
|
1721
|
+
Class.prototype[everyName] = function () {
|
|
1722
|
+
const args = Array.prototype.slice.call(arguments);
|
|
1723
|
+
const callback = args.pop();
|
|
1724
|
+
args.push((e, ea, s, t, sa, ta, u) => {
|
|
1725
|
+
return !callback(e, ea, s, t, sa, ta, u);
|
|
1726
|
+
});
|
|
1727
|
+
const found = this[findEdgeName].apply(this, args);
|
|
1728
|
+
if (found) return false;
|
|
1729
|
+
return true;
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function attachEdgeIteratorCreator(Class, description) {
|
|
1733
|
+
const { name: originalName, type, direction } = description;
|
|
1734
|
+
const name = originalName.slice(0, -1) + "Entries";
|
|
1735
|
+
Class.prototype[name] = function (source, target) {
|
|
1736
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return emptyIterator();
|
|
1737
|
+
if (!arguments.length) return createEdgeIterator(this, type);
|
|
1738
|
+
if (arguments.length === 1) {
|
|
1739
|
+
source = "" + source;
|
|
1740
|
+
const sourceData = this._nodes.get(source);
|
|
1741
|
+
if (!sourceData) throw new NotFoundGraphError(`Graph.${name}: could not find the "${source}" node in the graph.`);
|
|
1742
|
+
return createEdgeIteratorForNode(type, direction, sourceData);
|
|
1743
|
+
}
|
|
1744
|
+
if (arguments.length === 2) {
|
|
1745
|
+
source = "" + source;
|
|
1746
|
+
target = "" + target;
|
|
1747
|
+
const sourceData = this._nodes.get(source);
|
|
1748
|
+
if (!sourceData)
|
|
1749
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${source}" source node in the graph.`);
|
|
1750
|
+
if (!this._nodes.has(target))
|
|
1751
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${target}" target node in the graph.`);
|
|
1752
|
+
return createEdgeIteratorForPath(type, direction, sourceData, target);
|
|
1753
|
+
}
|
|
1754
|
+
throw new InvalidArgumentsGraphError(
|
|
1755
|
+
`Graph.${name}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`,
|
|
1756
|
+
);
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function attachEdgeIterationMethods(Graph2) {
|
|
1760
|
+
EDGES_ITERATION.forEach((description) => {
|
|
1761
|
+
attachEdgeArrayCreator(Graph2, description);
|
|
1762
|
+
attachForEachEdge(Graph2, description);
|
|
1763
|
+
attachFindEdge(Graph2, description);
|
|
1764
|
+
attachEdgeIteratorCreator(Graph2, description);
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
var NEIGHBORS_ITERATION = [
|
|
1768
|
+
{
|
|
1769
|
+
name: "neighbors",
|
|
1770
|
+
type: "mixed",
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
name: "inNeighbors",
|
|
1774
|
+
type: "directed",
|
|
1775
|
+
direction: "in",
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
name: "outNeighbors",
|
|
1779
|
+
type: "directed",
|
|
1780
|
+
direction: "out",
|
|
1781
|
+
},
|
|
1782
|
+
{
|
|
1783
|
+
name: "inboundNeighbors",
|
|
1784
|
+
type: "mixed",
|
|
1785
|
+
direction: "in",
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
name: "outboundNeighbors",
|
|
1789
|
+
type: "mixed",
|
|
1790
|
+
direction: "out",
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
name: "directedNeighbors",
|
|
1794
|
+
type: "directed",
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
name: "undirectedNeighbors",
|
|
1798
|
+
type: "undirected",
|
|
1799
|
+
},
|
|
1800
|
+
];
|
|
1801
|
+
function CompositeSetWrapper() {
|
|
1802
|
+
this.A = null;
|
|
1803
|
+
this.B = null;
|
|
1804
|
+
}
|
|
1805
|
+
CompositeSetWrapper.prototype.wrap = function (set) {
|
|
1806
|
+
if (this.A === null) this.A = set;
|
|
1807
|
+
else if (this.B === null) this.B = set;
|
|
1808
|
+
};
|
|
1809
|
+
CompositeSetWrapper.prototype.has = function (key) {
|
|
1810
|
+
if (this.A !== null && key in this.A) return true;
|
|
1811
|
+
if (this.B !== null && key in this.B) return true;
|
|
1812
|
+
return false;
|
|
1813
|
+
};
|
|
1814
|
+
function forEachInObjectOnce(breakable, visited, nodeData, object, callback) {
|
|
1815
|
+
for (const k in object) {
|
|
1816
|
+
const edgeData = object[k];
|
|
1817
|
+
const sourceData = edgeData.source;
|
|
1818
|
+
const targetData = edgeData.target;
|
|
1819
|
+
const neighborData = sourceData === nodeData ? targetData : sourceData;
|
|
1820
|
+
if (visited && visited.has(neighborData.key)) continue;
|
|
1821
|
+
const shouldBreak = callback(neighborData.key, neighborData.attributes);
|
|
1822
|
+
if (breakable && shouldBreak) return neighborData.key;
|
|
1823
|
+
}
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
function forEachNeighbor(breakable, type, direction, nodeData, callback) {
|
|
1827
|
+
if (type !== "mixed") {
|
|
1828
|
+
if (type === "undirected") return forEachInObjectOnce(breakable, null, nodeData, nodeData.undirected, callback);
|
|
1829
|
+
if (typeof direction === "string")
|
|
1830
|
+
return forEachInObjectOnce(breakable, null, nodeData, nodeData[direction], callback);
|
|
1831
|
+
}
|
|
1832
|
+
const visited = new CompositeSetWrapper();
|
|
1833
|
+
let found;
|
|
1834
|
+
if (type !== "undirected") {
|
|
1835
|
+
if (direction !== "out") {
|
|
1836
|
+
found = forEachInObjectOnce(breakable, null, nodeData, nodeData.in, callback);
|
|
1837
|
+
if (breakable && found) return found;
|
|
1838
|
+
visited.wrap(nodeData.in);
|
|
1839
|
+
}
|
|
1840
|
+
if (direction !== "in") {
|
|
1841
|
+
found = forEachInObjectOnce(breakable, visited, nodeData, nodeData.out, callback);
|
|
1842
|
+
if (breakable && found) return found;
|
|
1843
|
+
visited.wrap(nodeData.out);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (type !== "directed") {
|
|
1847
|
+
found = forEachInObjectOnce(breakable, visited, nodeData, nodeData.undirected, callback);
|
|
1848
|
+
if (breakable && found) return found;
|
|
1849
|
+
}
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
function createNeighborArrayForNode(type, direction, nodeData) {
|
|
1853
|
+
if (type !== "mixed") {
|
|
1854
|
+
if (type === "undirected") return Object.keys(nodeData.undirected);
|
|
1855
|
+
if (typeof direction === "string") return Object.keys(nodeData[direction]);
|
|
1856
|
+
}
|
|
1857
|
+
const neighbors = [];
|
|
1858
|
+
forEachNeighbor(false, type, direction, nodeData, function (key) {
|
|
1859
|
+
neighbors.push(key);
|
|
1860
|
+
});
|
|
1861
|
+
return neighbors;
|
|
1862
|
+
}
|
|
1863
|
+
function createDedupedObjectIterator(visited, nodeData, object) {
|
|
1864
|
+
const keys = Object.keys(object);
|
|
1865
|
+
const l = keys.length;
|
|
1866
|
+
let i = 0;
|
|
1867
|
+
return {
|
|
1868
|
+
[Symbol.iterator]() {
|
|
1869
|
+
return this;
|
|
1870
|
+
},
|
|
1871
|
+
next() {
|
|
1872
|
+
let neighborData = null;
|
|
1873
|
+
do {
|
|
1874
|
+
if (i >= l) {
|
|
1875
|
+
if (visited) visited.wrap(object);
|
|
1876
|
+
return { done: true };
|
|
1877
|
+
}
|
|
1878
|
+
const edgeData = object[keys[i++]];
|
|
1879
|
+
const sourceData = edgeData.source;
|
|
1880
|
+
const targetData = edgeData.target;
|
|
1881
|
+
neighborData = sourceData === nodeData ? targetData : sourceData;
|
|
1882
|
+
if (visited && visited.has(neighborData.key)) {
|
|
1883
|
+
neighborData = null;
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
} while (neighborData === null);
|
|
1887
|
+
return {
|
|
1888
|
+
done: false,
|
|
1889
|
+
value: { neighbor: neighborData.key, attributes: neighborData.attributes },
|
|
1890
|
+
};
|
|
1891
|
+
},
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
function createNeighborIterator(type, direction, nodeData) {
|
|
1895
|
+
if (type !== "mixed") {
|
|
1896
|
+
if (type === "undirected") return createDedupedObjectIterator(null, nodeData, nodeData.undirected);
|
|
1897
|
+
if (typeof direction === "string") return createDedupedObjectIterator(null, nodeData, nodeData[direction]);
|
|
1898
|
+
}
|
|
1899
|
+
let iterator = emptyIterator();
|
|
1900
|
+
const visited = new CompositeSetWrapper();
|
|
1901
|
+
if (type !== "undirected") {
|
|
1902
|
+
if (direction !== "out") {
|
|
1903
|
+
iterator = chain(iterator, createDedupedObjectIterator(visited, nodeData, nodeData.in));
|
|
1904
|
+
}
|
|
1905
|
+
if (direction !== "in") {
|
|
1906
|
+
iterator = chain(iterator, createDedupedObjectIterator(visited, nodeData, nodeData.out));
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
if (type !== "directed") {
|
|
1910
|
+
iterator = chain(iterator, createDedupedObjectIterator(visited, nodeData, nodeData.undirected));
|
|
1911
|
+
}
|
|
1912
|
+
return iterator;
|
|
1913
|
+
}
|
|
1914
|
+
function attachNeighborArrayCreator(Class, description) {
|
|
1915
|
+
const { name, type, direction } = description;
|
|
1916
|
+
Class.prototype[name] = function (node) {
|
|
1917
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return [];
|
|
1918
|
+
node = "" + node;
|
|
1919
|
+
const nodeData = this._nodes.get(node);
|
|
1920
|
+
if (typeof nodeData === "undefined")
|
|
1921
|
+
throw new NotFoundGraphError(`Graph.${name}: could not find the "${node}" node in the graph.`);
|
|
1922
|
+
return createNeighborArrayForNode(type === "mixed" ? this.type : type, direction, nodeData);
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
function attachForEachNeighbor(Class, description) {
|
|
1926
|
+
const { name, type, direction } = description;
|
|
1927
|
+
const forEachName = "forEach" + name[0].toUpperCase() + name.slice(1, -1);
|
|
1928
|
+
Class.prototype[forEachName] = function (node, callback) {
|
|
1929
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return;
|
|
1930
|
+
node = "" + node;
|
|
1931
|
+
const nodeData = this._nodes.get(node);
|
|
1932
|
+
if (typeof nodeData === "undefined")
|
|
1933
|
+
throw new NotFoundGraphError(`Graph.${forEachName}: could not find the "${node}" node in the graph.`);
|
|
1934
|
+
forEachNeighbor(false, type === "mixed" ? this.type : type, direction, nodeData, callback);
|
|
1935
|
+
};
|
|
1936
|
+
const mapName = "map" + name[0].toUpperCase() + name.slice(1);
|
|
1937
|
+
Class.prototype[mapName] = function (node, callback) {
|
|
1938
|
+
const result = [];
|
|
1939
|
+
this[forEachName](node, (n, a) => {
|
|
1940
|
+
result.push(callback(n, a));
|
|
1941
|
+
});
|
|
1942
|
+
return result;
|
|
1943
|
+
};
|
|
1944
|
+
const filterName = "filter" + name[0].toUpperCase() + name.slice(1);
|
|
1945
|
+
Class.prototype[filterName] = function (node, callback) {
|
|
1946
|
+
const result = [];
|
|
1947
|
+
this[forEachName](node, (n, a) => {
|
|
1948
|
+
if (callback(n, a)) result.push(n);
|
|
1949
|
+
});
|
|
1950
|
+
return result;
|
|
1951
|
+
};
|
|
1952
|
+
const reduceName = "reduce" + name[0].toUpperCase() + name.slice(1);
|
|
1953
|
+
Class.prototype[reduceName] = function (node, callback, initialValue) {
|
|
1954
|
+
if (arguments.length < 3)
|
|
1955
|
+
throw new InvalidArgumentsGraphError(
|
|
1956
|
+
`Graph.${reduceName}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`,
|
|
1957
|
+
);
|
|
1958
|
+
let accumulator = initialValue;
|
|
1959
|
+
this[forEachName](node, (n, a) => {
|
|
1960
|
+
accumulator = callback(accumulator, n, a);
|
|
1961
|
+
});
|
|
1962
|
+
return accumulator;
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
function attachFindNeighbor(Class, description) {
|
|
1966
|
+
const { name, type, direction } = description;
|
|
1967
|
+
const capitalizedSingular = name[0].toUpperCase() + name.slice(1, -1);
|
|
1968
|
+
const findName = "find" + capitalizedSingular;
|
|
1969
|
+
Class.prototype[findName] = function (node, callback) {
|
|
1970
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return;
|
|
1971
|
+
node = "" + node;
|
|
1972
|
+
const nodeData = this._nodes.get(node);
|
|
1973
|
+
if (typeof nodeData === "undefined")
|
|
1974
|
+
throw new NotFoundGraphError(`Graph.${findName}: could not find the "${node}" node in the graph.`);
|
|
1975
|
+
return forEachNeighbor(true, type === "mixed" ? this.type : type, direction, nodeData, callback);
|
|
1976
|
+
};
|
|
1977
|
+
const someName = "some" + capitalizedSingular;
|
|
1978
|
+
Class.prototype[someName] = function (node, callback) {
|
|
1979
|
+
const found = this[findName](node, callback);
|
|
1980
|
+
if (found) return true;
|
|
1981
|
+
return false;
|
|
1982
|
+
};
|
|
1983
|
+
const everyName = "every" + capitalizedSingular;
|
|
1984
|
+
Class.prototype[everyName] = function (node, callback) {
|
|
1985
|
+
const found = this[findName](node, (n, a) => {
|
|
1986
|
+
return !callback(n, a);
|
|
1987
|
+
});
|
|
1988
|
+
if (found) return false;
|
|
1989
|
+
return true;
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
function attachNeighborIteratorCreator(Class, description) {
|
|
1993
|
+
const { name, type, direction } = description;
|
|
1994
|
+
const iteratorName = name.slice(0, -1) + "Entries";
|
|
1995
|
+
Class.prototype[iteratorName] = function (node) {
|
|
1996
|
+
if (type !== "mixed" && this.type !== "mixed" && type !== this.type) return emptyIterator();
|
|
1997
|
+
node = "" + node;
|
|
1998
|
+
const nodeData = this._nodes.get(node);
|
|
1999
|
+
if (typeof nodeData === "undefined")
|
|
2000
|
+
throw new NotFoundGraphError(`Graph.${iteratorName}: could not find the "${node}" node in the graph.`);
|
|
2001
|
+
return createNeighborIterator(type === "mixed" ? this.type : type, direction, nodeData);
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
function attachNeighborIterationMethods(Graph2) {
|
|
2005
|
+
NEIGHBORS_ITERATION.forEach((description) => {
|
|
2006
|
+
attachNeighborArrayCreator(Graph2, description);
|
|
2007
|
+
attachForEachNeighbor(Graph2, description);
|
|
2008
|
+
attachFindNeighbor(Graph2, description);
|
|
2009
|
+
attachNeighborIteratorCreator(Graph2, description);
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
function forEachAdjacency(breakable, assymetric, disconnectedNodes, graph, callback) {
|
|
2013
|
+
const iterator = graph._nodes.values();
|
|
2014
|
+
const type = graph.type;
|
|
2015
|
+
let step, sourceData, neighbor, adj, edgeData, targetData, shouldBreak;
|
|
2016
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
2017
|
+
let hasEdges = false;
|
|
2018
|
+
sourceData = step.value;
|
|
2019
|
+
if (type !== "undirected") {
|
|
2020
|
+
adj = sourceData.out;
|
|
2021
|
+
for (neighbor in adj) {
|
|
2022
|
+
edgeData = adj[neighbor];
|
|
2023
|
+
do {
|
|
2024
|
+
targetData = edgeData.target;
|
|
2025
|
+
hasEdges = true;
|
|
2026
|
+
shouldBreak = callback(
|
|
2027
|
+
sourceData.key,
|
|
2028
|
+
targetData.key,
|
|
2029
|
+
sourceData.attributes,
|
|
2030
|
+
targetData.attributes,
|
|
2031
|
+
edgeData.key,
|
|
2032
|
+
edgeData.attributes,
|
|
2033
|
+
edgeData.undirected,
|
|
2034
|
+
);
|
|
2035
|
+
if (breakable && shouldBreak) return edgeData;
|
|
2036
|
+
edgeData = edgeData.next;
|
|
2037
|
+
} while (edgeData);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
if (type !== "directed") {
|
|
2041
|
+
adj = sourceData.undirected;
|
|
2042
|
+
for (neighbor in adj) {
|
|
2043
|
+
if (assymetric && sourceData.key > neighbor) continue;
|
|
2044
|
+
edgeData = adj[neighbor];
|
|
2045
|
+
do {
|
|
2046
|
+
targetData = edgeData.target;
|
|
2047
|
+
if (targetData.key !== neighbor) targetData = edgeData.source;
|
|
2048
|
+
hasEdges = true;
|
|
2049
|
+
shouldBreak = callback(
|
|
2050
|
+
sourceData.key,
|
|
2051
|
+
targetData.key,
|
|
2052
|
+
sourceData.attributes,
|
|
2053
|
+
targetData.attributes,
|
|
2054
|
+
edgeData.key,
|
|
2055
|
+
edgeData.attributes,
|
|
2056
|
+
edgeData.undirected,
|
|
2057
|
+
);
|
|
2058
|
+
if (breakable && shouldBreak) return edgeData;
|
|
2059
|
+
edgeData = edgeData.next;
|
|
2060
|
+
} while (edgeData);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if (disconnectedNodes && !hasEdges) {
|
|
2064
|
+
shouldBreak = callback(sourceData.key, null, sourceData.attributes, null, null, null, null);
|
|
2065
|
+
if (breakable && shouldBreak) return null;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
function serializeNode(key, data) {
|
|
2071
|
+
const serialized = { key };
|
|
2072
|
+
if (!isEmpty(data.attributes)) serialized.attributes = assign({}, data.attributes);
|
|
2073
|
+
return serialized;
|
|
2074
|
+
}
|
|
2075
|
+
function serializeEdge(type, key, data) {
|
|
2076
|
+
const serialized = {
|
|
2077
|
+
key,
|
|
2078
|
+
source: data.source.key,
|
|
2079
|
+
target: data.target.key,
|
|
2080
|
+
};
|
|
2081
|
+
if (!isEmpty(data.attributes)) serialized.attributes = assign({}, data.attributes);
|
|
2082
|
+
if (type === "mixed" && data.undirected) serialized.undirected = true;
|
|
2083
|
+
return serialized;
|
|
2084
|
+
}
|
|
2085
|
+
function validateSerializedNode(value) {
|
|
2086
|
+
if (!isPlainObject(value))
|
|
2087
|
+
throw new InvalidArgumentsGraphError(
|
|
2088
|
+
'Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.',
|
|
2089
|
+
);
|
|
2090
|
+
if (!("key" in value)) throw new InvalidArgumentsGraphError("Graph.import: serialized node is missing its key.");
|
|
2091
|
+
if ("attributes" in value && (!isPlainObject(value.attributes) || value.attributes === null))
|
|
2092
|
+
throw new InvalidArgumentsGraphError(
|
|
2093
|
+
"Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.",
|
|
2094
|
+
);
|
|
2095
|
+
}
|
|
2096
|
+
function validateSerializedEdge(value) {
|
|
2097
|
+
if (!isPlainObject(value))
|
|
2098
|
+
throw new InvalidArgumentsGraphError(
|
|
2099
|
+
'Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.',
|
|
2100
|
+
);
|
|
2101
|
+
if (!("source" in value))
|
|
2102
|
+
throw new InvalidArgumentsGraphError("Graph.import: serialized edge is missing its source.");
|
|
2103
|
+
if (!("target" in value))
|
|
2104
|
+
throw new InvalidArgumentsGraphError("Graph.import: serialized edge is missing its target.");
|
|
2105
|
+
if ("attributes" in value && (!isPlainObject(value.attributes) || value.attributes === null))
|
|
2106
|
+
throw new InvalidArgumentsGraphError(
|
|
2107
|
+
"Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.",
|
|
2108
|
+
);
|
|
2109
|
+
if ("undirected" in value && typeof value.undirected !== "boolean")
|
|
2110
|
+
throw new InvalidArgumentsGraphError(
|
|
2111
|
+
"Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.",
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
var INSTANCE_ID = incrementalIdStartingFromRandomByte();
|
|
2115
|
+
var TYPES = /* @__PURE__ */ new Set(["directed", "undirected", "mixed"]);
|
|
2116
|
+
var EMITTER_PROPS = /* @__PURE__ */ new Set(["domain", "_events", "_eventsCount", "_maxListeners"]);
|
|
2117
|
+
var EDGE_ADD_METHODS = [
|
|
2118
|
+
{
|
|
2119
|
+
name: (verb) => `${verb}Edge`,
|
|
2120
|
+
generateKey: true,
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
name: (verb) => `${verb}DirectedEdge`,
|
|
2124
|
+
generateKey: true,
|
|
2125
|
+
type: "directed",
|
|
2126
|
+
},
|
|
2127
|
+
{
|
|
2128
|
+
name: (verb) => `${verb}UndirectedEdge`,
|
|
2129
|
+
generateKey: true,
|
|
2130
|
+
type: "undirected",
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
name: (verb) => `${verb}EdgeWithKey`,
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
name: (verb) => `${verb}DirectedEdgeWithKey`,
|
|
2137
|
+
type: "directed",
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
name: (verb) => `${verb}UndirectedEdgeWithKey`,
|
|
2141
|
+
type: "undirected",
|
|
2142
|
+
},
|
|
2143
|
+
];
|
|
2144
|
+
var DEFAULTS = {
|
|
2145
|
+
allowSelfLoops: true,
|
|
2146
|
+
multi: false,
|
|
2147
|
+
type: "mixed",
|
|
2148
|
+
};
|
|
2149
|
+
function addNode(graph, node, attributes) {
|
|
2150
|
+
if (attributes && !isPlainObject(attributes))
|
|
2151
|
+
throw new InvalidArgumentsGraphError(
|
|
2152
|
+
`Graph.addNode: invalid attributes. Expecting an object but got "${attributes}"`,
|
|
2153
|
+
);
|
|
2154
|
+
node = "" + node;
|
|
2155
|
+
attributes = attributes || {};
|
|
2156
|
+
if (graph._nodes.has(node))
|
|
2157
|
+
throw new UsageGraphError(`Graph.addNode: the "${node}" node already exist in the graph.`);
|
|
2158
|
+
const data = new graph.NodeDataClass(node, attributes);
|
|
2159
|
+
graph._nodes.set(node, data);
|
|
2160
|
+
graph.emit("nodeAdded", {
|
|
2161
|
+
key: node,
|
|
2162
|
+
attributes,
|
|
2163
|
+
});
|
|
2164
|
+
return data;
|
|
2165
|
+
}
|
|
2166
|
+
function unsafeAddNode(graph, node, attributes) {
|
|
2167
|
+
const data = new graph.NodeDataClass(node, attributes);
|
|
2168
|
+
graph._nodes.set(node, data);
|
|
2169
|
+
graph.emit("nodeAdded", {
|
|
2170
|
+
key: node,
|
|
2171
|
+
attributes,
|
|
2172
|
+
});
|
|
2173
|
+
return data;
|
|
2174
|
+
}
|
|
2175
|
+
function addEdge(graph, name, mustGenerateKey, undirected, edge, source, target, attributes) {
|
|
2176
|
+
if (!undirected && graph.type === "undirected")
|
|
2177
|
+
throw new UsageGraphError(
|
|
2178
|
+
`Graph.${name}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`,
|
|
2179
|
+
);
|
|
2180
|
+
if (undirected && graph.type === "directed")
|
|
2181
|
+
throw new UsageGraphError(
|
|
2182
|
+
`Graph.${name}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`,
|
|
2183
|
+
);
|
|
2184
|
+
if (attributes && !isPlainObject(attributes))
|
|
2185
|
+
throw new InvalidArgumentsGraphError(
|
|
2186
|
+
`Graph.${name}: invalid attributes. Expecting an object but got "${attributes}"`,
|
|
2187
|
+
);
|
|
2188
|
+
source = "" + source;
|
|
2189
|
+
target = "" + target;
|
|
2190
|
+
attributes = attributes || {};
|
|
2191
|
+
if (!graph.allowSelfLoops && source === target)
|
|
2192
|
+
throw new UsageGraphError(
|
|
2193
|
+
`Graph.${name}: source & target are the same ("${source}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`,
|
|
2194
|
+
);
|
|
2195
|
+
const sourceData = graph._nodes.get(source),
|
|
2196
|
+
targetData = graph._nodes.get(target);
|
|
2197
|
+
if (!sourceData) throw new NotFoundGraphError(`Graph.${name}: source node "${source}" not found.`);
|
|
2198
|
+
if (!targetData) throw new NotFoundGraphError(`Graph.${name}: target node "${target}" not found.`);
|
|
2199
|
+
const eventData = {
|
|
2200
|
+
key: null,
|
|
2201
|
+
undirected,
|
|
2202
|
+
source,
|
|
2203
|
+
target,
|
|
2204
|
+
attributes,
|
|
2205
|
+
};
|
|
2206
|
+
if (mustGenerateKey) {
|
|
2207
|
+
edge = graph._edgeKeyGenerator();
|
|
2208
|
+
} else {
|
|
2209
|
+
edge = "" + edge;
|
|
2210
|
+
if (graph._edges.has(edge))
|
|
2211
|
+
throw new UsageGraphError(`Graph.${name}: the "${edge}" edge already exists in the graph.`);
|
|
2212
|
+
}
|
|
2213
|
+
if (
|
|
2214
|
+
!graph.multi &&
|
|
2215
|
+
(undirected ? typeof sourceData.undirected[target] !== "undefined" : typeof sourceData.out[target] !== "undefined")
|
|
2216
|
+
) {
|
|
2217
|
+
throw new UsageGraphError(
|
|
2218
|
+
`Graph.${name}: an edge linking "${source}" to "${target}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`,
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
const edgeData = new EdgeData(undirected, edge, sourceData, targetData, attributes);
|
|
2222
|
+
graph._edges.set(edge, edgeData);
|
|
2223
|
+
const isSelfLoop = source === target;
|
|
2224
|
+
if (undirected) {
|
|
2225
|
+
sourceData.undirectedDegree++;
|
|
2226
|
+
targetData.undirectedDegree++;
|
|
2227
|
+
if (isSelfLoop) {
|
|
2228
|
+
sourceData.undirectedLoops++;
|
|
2229
|
+
graph._undirectedSelfLoopCount++;
|
|
2230
|
+
}
|
|
2231
|
+
} else {
|
|
2232
|
+
sourceData.outDegree++;
|
|
2233
|
+
targetData.inDegree++;
|
|
2234
|
+
if (isSelfLoop) {
|
|
2235
|
+
sourceData.directedLoops++;
|
|
2236
|
+
graph._directedSelfLoopCount++;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
if (graph.multi) edgeData.attachMulti();
|
|
2240
|
+
else edgeData.attach();
|
|
2241
|
+
if (undirected) graph._undirectedSize++;
|
|
2242
|
+
else graph._directedSize++;
|
|
2243
|
+
eventData.key = edge;
|
|
2244
|
+
graph.emit("edgeAdded", eventData);
|
|
2245
|
+
return edge;
|
|
2246
|
+
}
|
|
2247
|
+
function mergeEdge(graph, name, mustGenerateKey, undirected, edge, source, target, attributes, asUpdater) {
|
|
2248
|
+
if (!undirected && graph.type === "undirected")
|
|
2249
|
+
throw new UsageGraphError(
|
|
2250
|
+
`Graph.${name}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`,
|
|
2251
|
+
);
|
|
2252
|
+
if (undirected && graph.type === "directed")
|
|
2253
|
+
throw new UsageGraphError(
|
|
2254
|
+
`Graph.${name}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`,
|
|
2255
|
+
);
|
|
2256
|
+
if (attributes) {
|
|
2257
|
+
if (asUpdater) {
|
|
2258
|
+
if (typeof attributes !== "function")
|
|
2259
|
+
throw new InvalidArgumentsGraphError(
|
|
2260
|
+
`Graph.${name}: invalid updater function. Expecting a function but got "${attributes}"`,
|
|
2261
|
+
);
|
|
2262
|
+
} else {
|
|
2263
|
+
if (!isPlainObject(attributes))
|
|
2264
|
+
throw new InvalidArgumentsGraphError(
|
|
2265
|
+
`Graph.${name}: invalid attributes. Expecting an object but got "${attributes}"`,
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
source = "" + source;
|
|
2270
|
+
target = "" + target;
|
|
2271
|
+
let updater;
|
|
2272
|
+
if (asUpdater) {
|
|
2273
|
+
updater = attributes;
|
|
2274
|
+
attributes = void 0;
|
|
2275
|
+
}
|
|
2276
|
+
if (!graph.allowSelfLoops && source === target)
|
|
2277
|
+
throw new UsageGraphError(
|
|
2278
|
+
`Graph.${name}: source & target are the same ("${source}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`,
|
|
2279
|
+
);
|
|
2280
|
+
let sourceData = graph._nodes.get(source);
|
|
2281
|
+
let targetData = graph._nodes.get(target);
|
|
2282
|
+
let edgeData;
|
|
2283
|
+
let alreadyExistingEdgeData;
|
|
2284
|
+
if (!mustGenerateKey) {
|
|
2285
|
+
edgeData = graph._edges.get(edge);
|
|
2286
|
+
if (edgeData) {
|
|
2287
|
+
if (edgeData.source.key !== source || edgeData.target.key !== target) {
|
|
2288
|
+
if (!undirected || edgeData.source.key !== target || edgeData.target.key !== source) {
|
|
2289
|
+
throw new UsageGraphError(
|
|
2290
|
+
`Graph.${name}: inconsistency detected when attempting to merge the "${edge}" edge with "${source}" source & "${target}" target vs. ("${edgeData.source.key}", "${edgeData.target.key}").`,
|
|
2291
|
+
);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
alreadyExistingEdgeData = edgeData;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
if (!alreadyExistingEdgeData && !graph.multi && sourceData) {
|
|
2298
|
+
alreadyExistingEdgeData = undirected ? sourceData.undirected[target] : sourceData.out[target];
|
|
2299
|
+
}
|
|
2300
|
+
if (alreadyExistingEdgeData) {
|
|
2301
|
+
const info = [alreadyExistingEdgeData.key, false, false, false];
|
|
2302
|
+
if (asUpdater ? !updater : !attributes) return info;
|
|
2303
|
+
if (asUpdater) {
|
|
2304
|
+
const oldAttributes = alreadyExistingEdgeData.attributes;
|
|
2305
|
+
alreadyExistingEdgeData.attributes = updater(oldAttributes);
|
|
2306
|
+
graph.emit("edgeAttributesUpdated", {
|
|
2307
|
+
type: "replace",
|
|
2308
|
+
key: alreadyExistingEdgeData.key,
|
|
2309
|
+
attributes: alreadyExistingEdgeData.attributes,
|
|
2310
|
+
});
|
|
2311
|
+
} else {
|
|
2312
|
+
assign(alreadyExistingEdgeData.attributes, attributes);
|
|
2313
|
+
graph.emit("edgeAttributesUpdated", {
|
|
2314
|
+
type: "merge",
|
|
2315
|
+
key: alreadyExistingEdgeData.key,
|
|
2316
|
+
attributes: alreadyExistingEdgeData.attributes,
|
|
2317
|
+
data: attributes,
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
return info;
|
|
2321
|
+
}
|
|
2322
|
+
attributes = attributes || {};
|
|
2323
|
+
if (asUpdater && updater) attributes = updater(attributes);
|
|
2324
|
+
const eventData = {
|
|
2325
|
+
key: null,
|
|
2326
|
+
undirected,
|
|
2327
|
+
source,
|
|
2328
|
+
target,
|
|
2329
|
+
attributes,
|
|
2330
|
+
};
|
|
2331
|
+
if (mustGenerateKey) {
|
|
2332
|
+
edge = graph._edgeKeyGenerator();
|
|
2333
|
+
} else {
|
|
2334
|
+
edge = "" + edge;
|
|
2335
|
+
if (graph._edges.has(edge))
|
|
2336
|
+
throw new UsageGraphError(`Graph.${name}: the "${edge}" edge already exists in the graph.`);
|
|
2337
|
+
}
|
|
2338
|
+
let sourceWasAdded = false;
|
|
2339
|
+
let targetWasAdded = false;
|
|
2340
|
+
if (!sourceData) {
|
|
2341
|
+
sourceData = unsafeAddNode(graph, source, {});
|
|
2342
|
+
sourceWasAdded = true;
|
|
2343
|
+
if (source === target) {
|
|
2344
|
+
targetData = sourceData;
|
|
2345
|
+
targetWasAdded = true;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
if (!targetData) {
|
|
2349
|
+
targetData = unsafeAddNode(graph, target, {});
|
|
2350
|
+
targetWasAdded = true;
|
|
2351
|
+
}
|
|
2352
|
+
edgeData = new EdgeData(undirected, edge, sourceData, targetData, attributes);
|
|
2353
|
+
graph._edges.set(edge, edgeData);
|
|
2354
|
+
const isSelfLoop = source === target;
|
|
2355
|
+
if (undirected) {
|
|
2356
|
+
sourceData.undirectedDegree++;
|
|
2357
|
+
targetData.undirectedDegree++;
|
|
2358
|
+
if (isSelfLoop) {
|
|
2359
|
+
sourceData.undirectedLoops++;
|
|
2360
|
+
graph._undirectedSelfLoopCount++;
|
|
2361
|
+
}
|
|
2362
|
+
} else {
|
|
2363
|
+
sourceData.outDegree++;
|
|
2364
|
+
targetData.inDegree++;
|
|
2365
|
+
if (isSelfLoop) {
|
|
2366
|
+
sourceData.directedLoops++;
|
|
2367
|
+
graph._directedSelfLoopCount++;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
if (graph.multi) edgeData.attachMulti();
|
|
2371
|
+
else edgeData.attach();
|
|
2372
|
+
if (undirected) graph._undirectedSize++;
|
|
2373
|
+
else graph._directedSize++;
|
|
2374
|
+
eventData.key = edge;
|
|
2375
|
+
graph.emit("edgeAdded", eventData);
|
|
2376
|
+
return [edge, true, sourceWasAdded, targetWasAdded];
|
|
2377
|
+
}
|
|
2378
|
+
function dropEdgeFromData(graph, edgeData) {
|
|
2379
|
+
graph._edges.delete(edgeData.key);
|
|
2380
|
+
const { source: sourceData, target: targetData, attributes } = edgeData;
|
|
2381
|
+
const undirected = edgeData.undirected;
|
|
2382
|
+
const isSelfLoop = sourceData === targetData;
|
|
2383
|
+
if (undirected) {
|
|
2384
|
+
sourceData.undirectedDegree--;
|
|
2385
|
+
targetData.undirectedDegree--;
|
|
2386
|
+
if (isSelfLoop) {
|
|
2387
|
+
sourceData.undirectedLoops--;
|
|
2388
|
+
graph._undirectedSelfLoopCount--;
|
|
2389
|
+
}
|
|
2390
|
+
} else {
|
|
2391
|
+
sourceData.outDegree--;
|
|
2392
|
+
targetData.inDegree--;
|
|
2393
|
+
if (isSelfLoop) {
|
|
2394
|
+
sourceData.directedLoops--;
|
|
2395
|
+
graph._directedSelfLoopCount--;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
if (graph.multi) edgeData.detachMulti();
|
|
2399
|
+
else edgeData.detach();
|
|
2400
|
+
if (undirected) graph._undirectedSize--;
|
|
2401
|
+
else graph._directedSize--;
|
|
2402
|
+
graph.emit("edgeDropped", {
|
|
2403
|
+
key: edgeData.key,
|
|
2404
|
+
attributes,
|
|
2405
|
+
source: sourceData.key,
|
|
2406
|
+
target: targetData.key,
|
|
2407
|
+
undirected,
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
var Graph = class _Graph extends import_events.EventEmitter {
|
|
2411
|
+
constructor(options) {
|
|
2412
|
+
super();
|
|
2413
|
+
options = assign({}, DEFAULTS, options);
|
|
2414
|
+
if (typeof options.multi !== "boolean")
|
|
2415
|
+
throw new InvalidArgumentsGraphError(
|
|
2416
|
+
`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${options.multi}".`,
|
|
2417
|
+
);
|
|
2418
|
+
if (!TYPES.has(options.type))
|
|
2419
|
+
throw new InvalidArgumentsGraphError(
|
|
2420
|
+
`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${options.type}".`,
|
|
2421
|
+
);
|
|
2422
|
+
if (typeof options.allowSelfLoops !== "boolean")
|
|
2423
|
+
throw new InvalidArgumentsGraphError(
|
|
2424
|
+
`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${options.allowSelfLoops}".`,
|
|
2425
|
+
);
|
|
2426
|
+
const NodeDataClass =
|
|
2427
|
+
options.type === "mixed" ? MixedNodeData : options.type === "directed" ? DirectedNodeData : UndirectedNodeData;
|
|
2428
|
+
privateProperty(this, "NodeDataClass", NodeDataClass);
|
|
2429
|
+
const instancePrefix = "geid_" + INSTANCE_ID() + "_";
|
|
2430
|
+
let edgeId = 0;
|
|
2431
|
+
const edgeKeyGenerator = () => {
|
|
2432
|
+
let availableEdgeKey;
|
|
2433
|
+
do {
|
|
2434
|
+
availableEdgeKey = instancePrefix + edgeId++;
|
|
2435
|
+
} while (this._edges.has(availableEdgeKey));
|
|
2436
|
+
return availableEdgeKey;
|
|
2437
|
+
};
|
|
2438
|
+
privateProperty(this, "_attributes", {});
|
|
2439
|
+
privateProperty(this, "_nodes", /* @__PURE__ */ new Map());
|
|
2440
|
+
privateProperty(this, "_edges", /* @__PURE__ */ new Map());
|
|
2441
|
+
privateProperty(this, "_directedSize", 0);
|
|
2442
|
+
privateProperty(this, "_undirectedSize", 0);
|
|
2443
|
+
privateProperty(this, "_directedSelfLoopCount", 0);
|
|
2444
|
+
privateProperty(this, "_undirectedSelfLoopCount", 0);
|
|
2445
|
+
privateProperty(this, "_edgeKeyGenerator", edgeKeyGenerator);
|
|
2446
|
+
privateProperty(this, "_options", options);
|
|
2447
|
+
EMITTER_PROPS.forEach((prop) => privateProperty(this, prop, this[prop]));
|
|
2448
|
+
readOnlyProperty(this, "order", () => this._nodes.size);
|
|
2449
|
+
readOnlyProperty(this, "size", () => this._edges.size);
|
|
2450
|
+
readOnlyProperty(this, "directedSize", () => this._directedSize);
|
|
2451
|
+
readOnlyProperty(this, "undirectedSize", () => this._undirectedSize);
|
|
2452
|
+
readOnlyProperty(this, "selfLoopCount", () => this._directedSelfLoopCount + this._undirectedSelfLoopCount);
|
|
2453
|
+
readOnlyProperty(this, "directedSelfLoopCount", () => this._directedSelfLoopCount);
|
|
2454
|
+
readOnlyProperty(this, "undirectedSelfLoopCount", () => this._undirectedSelfLoopCount);
|
|
2455
|
+
readOnlyProperty(this, "multi", this._options.multi);
|
|
2456
|
+
readOnlyProperty(this, "type", this._options.type);
|
|
2457
|
+
readOnlyProperty(this, "allowSelfLoops", this._options.allowSelfLoops);
|
|
2458
|
+
readOnlyProperty(this, "implementation", () => "graphology");
|
|
2459
|
+
}
|
|
2460
|
+
_resetInstanceCounters() {
|
|
2461
|
+
this._directedSize = 0;
|
|
2462
|
+
this._undirectedSize = 0;
|
|
2463
|
+
this._directedSelfLoopCount = 0;
|
|
2464
|
+
this._undirectedSelfLoopCount = 0;
|
|
2465
|
+
}
|
|
2466
|
+
/**---------------------------------------------------------------------------
|
|
2467
|
+
* Read
|
|
2468
|
+
**---------------------------------------------------------------------------
|
|
2469
|
+
*/
|
|
2470
|
+
/**
|
|
2471
|
+
* Method returning whether the given node is found in the graph.
|
|
2472
|
+
*
|
|
2473
|
+
* @param {any} node - The node.
|
|
2474
|
+
* @return {boolean}
|
|
2475
|
+
*/
|
|
2476
|
+
hasNode(node) {
|
|
2477
|
+
return this._nodes.has("" + node);
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Method returning whether the given directed edge is found in the graph.
|
|
2481
|
+
*
|
|
2482
|
+
* Arity 1:
|
|
2483
|
+
* @param {any} edge - The edge's key.
|
|
2484
|
+
*
|
|
2485
|
+
* Arity 2:
|
|
2486
|
+
* @param {any} source - The edge's source.
|
|
2487
|
+
* @param {any} target - The edge's target.
|
|
2488
|
+
*
|
|
2489
|
+
* @return {boolean}
|
|
2490
|
+
*
|
|
2491
|
+
* @throws {Error} - Will throw if the arguments are invalid.
|
|
2492
|
+
*/
|
|
2493
|
+
hasDirectedEdge(source, target) {
|
|
2494
|
+
if (this.type === "undirected") return false;
|
|
2495
|
+
if (arguments.length === 1) {
|
|
2496
|
+
const edge = "" + source;
|
|
2497
|
+
const edgeData = this._edges.get(edge);
|
|
2498
|
+
return !!edgeData && !edgeData.undirected;
|
|
2499
|
+
} else if (arguments.length === 2) {
|
|
2500
|
+
source = "" + source;
|
|
2501
|
+
target = "" + target;
|
|
2502
|
+
const nodeData = this._nodes.get(source);
|
|
2503
|
+
if (!nodeData) return false;
|
|
2504
|
+
return nodeData.out.hasOwnProperty(target);
|
|
2505
|
+
}
|
|
2506
|
+
throw new InvalidArgumentsGraphError(
|
|
2507
|
+
`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`,
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
/**
|
|
2511
|
+
* Method returning whether the given undirected edge is found in the graph.
|
|
2512
|
+
*
|
|
2513
|
+
* Arity 1:
|
|
2514
|
+
* @param {any} edge - The edge's key.
|
|
2515
|
+
*
|
|
2516
|
+
* Arity 2:
|
|
2517
|
+
* @param {any} source - The edge's source.
|
|
2518
|
+
* @param {any} target - The edge's target.
|
|
2519
|
+
*
|
|
2520
|
+
* @return {boolean}
|
|
2521
|
+
*
|
|
2522
|
+
* @throws {Error} - Will throw if the arguments are invalid.
|
|
2523
|
+
*/
|
|
2524
|
+
hasUndirectedEdge(source, target) {
|
|
2525
|
+
if (this.type === "directed") return false;
|
|
2526
|
+
if (arguments.length === 1) {
|
|
2527
|
+
const edge = "" + source;
|
|
2528
|
+
const edgeData = this._edges.get(edge);
|
|
2529
|
+
return !!edgeData && edgeData.undirected;
|
|
2530
|
+
} else if (arguments.length === 2) {
|
|
2531
|
+
source = "" + source;
|
|
2532
|
+
target = "" + target;
|
|
2533
|
+
const nodeData = this._nodes.get(source);
|
|
2534
|
+
if (!nodeData) return false;
|
|
2535
|
+
return nodeData.undirected.hasOwnProperty(target);
|
|
2536
|
+
}
|
|
2537
|
+
throw new InvalidArgumentsGraphError(
|
|
2538
|
+
`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`,
|
|
2539
|
+
);
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Method returning whether the given edge is found in the graph.
|
|
2543
|
+
*
|
|
2544
|
+
* Arity 1:
|
|
2545
|
+
* @param {any} edge - The edge's key.
|
|
2546
|
+
*
|
|
2547
|
+
* Arity 2:
|
|
2548
|
+
* @param {any} source - The edge's source.
|
|
2549
|
+
* @param {any} target - The edge's target.
|
|
2550
|
+
*
|
|
2551
|
+
* @return {boolean}
|
|
2552
|
+
*
|
|
2553
|
+
* @throws {Error} - Will throw if the arguments are invalid.
|
|
2554
|
+
*/
|
|
2555
|
+
hasEdge(source, target) {
|
|
2556
|
+
if (arguments.length === 1) {
|
|
2557
|
+
const edge = "" + source;
|
|
2558
|
+
return this._edges.has(edge);
|
|
2559
|
+
} else if (arguments.length === 2) {
|
|
2560
|
+
source = "" + source;
|
|
2561
|
+
target = "" + target;
|
|
2562
|
+
const nodeData = this._nodes.get(source);
|
|
2563
|
+
if (!nodeData) return false;
|
|
2564
|
+
return (
|
|
2565
|
+
(typeof nodeData.out !== "undefined" && nodeData.out.hasOwnProperty(target)) ||
|
|
2566
|
+
(typeof nodeData.undirected !== "undefined" && nodeData.undirected.hasOwnProperty(target))
|
|
2567
|
+
);
|
|
2568
|
+
}
|
|
2569
|
+
throw new InvalidArgumentsGraphError(
|
|
2570
|
+
`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`,
|
|
2571
|
+
);
|
|
2572
|
+
}
|
|
2573
|
+
/**
|
|
2574
|
+
* Method returning the edge matching source & target in a directed fashion.
|
|
2575
|
+
*
|
|
2576
|
+
* @param {any} source - The edge's source.
|
|
2577
|
+
* @param {any} target - The edge's target.
|
|
2578
|
+
*
|
|
2579
|
+
* @return {any|undefined}
|
|
2580
|
+
*
|
|
2581
|
+
* @throws {Error} - Will throw if the graph is multi.
|
|
2582
|
+
* @throws {Error} - Will throw if source or target doesn't exist.
|
|
2583
|
+
*/
|
|
2584
|
+
directedEdge(source, target) {
|
|
2585
|
+
if (this.type === "undirected") return;
|
|
2586
|
+
source = "" + source;
|
|
2587
|
+
target = "" + target;
|
|
2588
|
+
if (this.multi)
|
|
2589
|
+
throw new UsageGraphError(
|
|
2590
|
+
"Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.",
|
|
2591
|
+
);
|
|
2592
|
+
const sourceData = this._nodes.get(source);
|
|
2593
|
+
if (!sourceData)
|
|
2594
|
+
throw new NotFoundGraphError(`Graph.directedEdge: could not find the "${source}" source node in the graph.`);
|
|
2595
|
+
if (!this._nodes.has(target))
|
|
2596
|
+
throw new NotFoundGraphError(`Graph.directedEdge: could not find the "${target}" target node in the graph.`);
|
|
2597
|
+
const edgeData = (sourceData.out && sourceData.out[target]) || void 0;
|
|
2598
|
+
if (edgeData) return edgeData.key;
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Method returning the edge matching source & target in a undirected fashion.
|
|
2602
|
+
*
|
|
2603
|
+
* @param {any} source - The edge's source.
|
|
2604
|
+
* @param {any} target - The edge's target.
|
|
2605
|
+
*
|
|
2606
|
+
* @return {any|undefined}
|
|
2607
|
+
*
|
|
2608
|
+
* @throws {Error} - Will throw if the graph is multi.
|
|
2609
|
+
* @throws {Error} - Will throw if source or target doesn't exist.
|
|
2610
|
+
*/
|
|
2611
|
+
undirectedEdge(source, target) {
|
|
2612
|
+
if (this.type === "directed") return;
|
|
2613
|
+
source = "" + source;
|
|
2614
|
+
target = "" + target;
|
|
2615
|
+
if (this.multi)
|
|
2616
|
+
throw new UsageGraphError(
|
|
2617
|
+
"Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.",
|
|
2618
|
+
);
|
|
2619
|
+
const sourceData = this._nodes.get(source);
|
|
2620
|
+
if (!sourceData)
|
|
2621
|
+
throw new NotFoundGraphError(`Graph.undirectedEdge: could not find the "${source}" source node in the graph.`);
|
|
2622
|
+
if (!this._nodes.has(target))
|
|
2623
|
+
throw new NotFoundGraphError(`Graph.undirectedEdge: could not find the "${target}" target node in the graph.`);
|
|
2624
|
+
const edgeData = (sourceData.undirected && sourceData.undirected[target]) || void 0;
|
|
2625
|
+
if (edgeData) return edgeData.key;
|
|
2626
|
+
}
|
|
2627
|
+
/**
|
|
2628
|
+
* Method returning the edge matching source & target in a mixed fashion.
|
|
2629
|
+
*
|
|
2630
|
+
* @param {any} source - The edge's source.
|
|
2631
|
+
* @param {any} target - The edge's target.
|
|
2632
|
+
*
|
|
2633
|
+
* @return {any|undefined}
|
|
2634
|
+
*
|
|
2635
|
+
* @throws {Error} - Will throw if the graph is multi.
|
|
2636
|
+
* @throws {Error} - Will throw if source or target doesn't exist.
|
|
2637
|
+
*/
|
|
2638
|
+
edge(source, target) {
|
|
2639
|
+
if (this.multi)
|
|
2640
|
+
throw new UsageGraphError(
|
|
2641
|
+
"Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.",
|
|
2642
|
+
);
|
|
2643
|
+
source = "" + source;
|
|
2644
|
+
target = "" + target;
|
|
2645
|
+
const sourceData = this._nodes.get(source);
|
|
2646
|
+
if (!sourceData)
|
|
2647
|
+
throw new NotFoundGraphError(`Graph.edge: could not find the "${source}" source node in the graph.`);
|
|
2648
|
+
if (!this._nodes.has(target))
|
|
2649
|
+
throw new NotFoundGraphError(`Graph.edge: could not find the "${target}" target node in the graph.`);
|
|
2650
|
+
const edgeData =
|
|
2651
|
+
(sourceData.out && sourceData.out[target]) || (sourceData.undirected && sourceData.undirected[target]) || void 0;
|
|
2652
|
+
if (edgeData) return edgeData.key;
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Method returning whether two nodes are directed neighbors.
|
|
2656
|
+
*
|
|
2657
|
+
* @param {any} node - The node's key.
|
|
2658
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2659
|
+
* @return {boolean}
|
|
2660
|
+
*
|
|
2661
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2662
|
+
*/
|
|
2663
|
+
areDirectedNeighbors(node, neighbor) {
|
|
2664
|
+
node = "" + node;
|
|
2665
|
+
neighbor = "" + neighbor;
|
|
2666
|
+
const nodeData = this._nodes.get(node);
|
|
2667
|
+
if (!nodeData)
|
|
2668
|
+
throw new NotFoundGraphError(`Graph.areDirectedNeighbors: could not find the "${node}" node in the graph.`);
|
|
2669
|
+
if (this.type === "undirected") return false;
|
|
2670
|
+
return neighbor in nodeData.in || neighbor in nodeData.out;
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* Method returning whether two nodes are out neighbors.
|
|
2674
|
+
*
|
|
2675
|
+
* @param {any} node - The node's key.
|
|
2676
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2677
|
+
* @return {boolean}
|
|
2678
|
+
*
|
|
2679
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2680
|
+
*/
|
|
2681
|
+
areOutNeighbors(node, neighbor) {
|
|
2682
|
+
node = "" + node;
|
|
2683
|
+
neighbor = "" + neighbor;
|
|
2684
|
+
const nodeData = this._nodes.get(node);
|
|
2685
|
+
if (!nodeData)
|
|
2686
|
+
throw new NotFoundGraphError(`Graph.areOutNeighbors: could not find the "${node}" node in the graph.`);
|
|
2687
|
+
if (this.type === "undirected") return false;
|
|
2688
|
+
return neighbor in nodeData.out;
|
|
2689
|
+
}
|
|
2690
|
+
/**
|
|
2691
|
+
* Method returning whether two nodes are in neighbors.
|
|
2692
|
+
*
|
|
2693
|
+
* @param {any} node - The node's key.
|
|
2694
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2695
|
+
* @return {boolean}
|
|
2696
|
+
*
|
|
2697
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2698
|
+
*/
|
|
2699
|
+
areInNeighbors(node, neighbor) {
|
|
2700
|
+
node = "" + node;
|
|
2701
|
+
neighbor = "" + neighbor;
|
|
2702
|
+
const nodeData = this._nodes.get(node);
|
|
2703
|
+
if (!nodeData)
|
|
2704
|
+
throw new NotFoundGraphError(`Graph.areInNeighbors: could not find the "${node}" node in the graph.`);
|
|
2705
|
+
if (this.type === "undirected") return false;
|
|
2706
|
+
return neighbor in nodeData.in;
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Method returning whether two nodes are undirected neighbors.
|
|
2710
|
+
*
|
|
2711
|
+
* @param {any} node - The node's key.
|
|
2712
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2713
|
+
* @return {boolean}
|
|
2714
|
+
*
|
|
2715
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2716
|
+
*/
|
|
2717
|
+
areUndirectedNeighbors(node, neighbor) {
|
|
2718
|
+
node = "" + node;
|
|
2719
|
+
neighbor = "" + neighbor;
|
|
2720
|
+
const nodeData = this._nodes.get(node);
|
|
2721
|
+
if (!nodeData)
|
|
2722
|
+
throw new NotFoundGraphError(`Graph.areUndirectedNeighbors: could not find the "${node}" node in the graph.`);
|
|
2723
|
+
if (this.type === "directed") return false;
|
|
2724
|
+
return neighbor in nodeData.undirected;
|
|
2725
|
+
}
|
|
2726
|
+
/**
|
|
2727
|
+
* Method returning whether two nodes are neighbors.
|
|
2728
|
+
*
|
|
2729
|
+
* @param {any} node - The node's key.
|
|
2730
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2731
|
+
* @return {boolean}
|
|
2732
|
+
*
|
|
2733
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2734
|
+
*/
|
|
2735
|
+
areNeighbors(node, neighbor) {
|
|
2736
|
+
node = "" + node;
|
|
2737
|
+
neighbor = "" + neighbor;
|
|
2738
|
+
const nodeData = this._nodes.get(node);
|
|
2739
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.areNeighbors: could not find the "${node}" node in the graph.`);
|
|
2740
|
+
if (this.type !== "undirected") {
|
|
2741
|
+
if (neighbor in nodeData.in || neighbor in nodeData.out) return true;
|
|
2742
|
+
}
|
|
2743
|
+
if (this.type !== "directed") {
|
|
2744
|
+
if (neighbor in nodeData.undirected) return true;
|
|
2745
|
+
}
|
|
2746
|
+
return false;
|
|
2747
|
+
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Method returning whether two nodes are inbound neighbors.
|
|
2750
|
+
*
|
|
2751
|
+
* @param {any} node - The node's key.
|
|
2752
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2753
|
+
* @return {boolean}
|
|
2754
|
+
*
|
|
2755
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2756
|
+
*/
|
|
2757
|
+
areInboundNeighbors(node, neighbor) {
|
|
2758
|
+
node = "" + node;
|
|
2759
|
+
neighbor = "" + neighbor;
|
|
2760
|
+
const nodeData = this._nodes.get(node);
|
|
2761
|
+
if (!nodeData)
|
|
2762
|
+
throw new NotFoundGraphError(`Graph.areInboundNeighbors: could not find the "${node}" node in the graph.`);
|
|
2763
|
+
if (this.type !== "undirected") {
|
|
2764
|
+
if (neighbor in nodeData.in) return true;
|
|
2765
|
+
}
|
|
2766
|
+
if (this.type !== "directed") {
|
|
2767
|
+
if (neighbor in nodeData.undirected) return true;
|
|
2768
|
+
}
|
|
2769
|
+
return false;
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Method returning whether two nodes are outbound neighbors.
|
|
2773
|
+
*
|
|
2774
|
+
* @param {any} node - The node's key.
|
|
2775
|
+
* @param {any} neighbor - The neighbor's key.
|
|
2776
|
+
* @return {boolean}
|
|
2777
|
+
*
|
|
2778
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2779
|
+
*/
|
|
2780
|
+
areOutboundNeighbors(node, neighbor) {
|
|
2781
|
+
node = "" + node;
|
|
2782
|
+
neighbor = "" + neighbor;
|
|
2783
|
+
const nodeData = this._nodes.get(node);
|
|
2784
|
+
if (!nodeData)
|
|
2785
|
+
throw new NotFoundGraphError(`Graph.areOutboundNeighbors: could not find the "${node}" node in the graph.`);
|
|
2786
|
+
if (this.type !== "undirected") {
|
|
2787
|
+
if (neighbor in nodeData.out) return true;
|
|
2788
|
+
}
|
|
2789
|
+
if (this.type !== "directed") {
|
|
2790
|
+
if (neighbor in nodeData.undirected) return true;
|
|
2791
|
+
}
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
/**
|
|
2795
|
+
* Method returning the given node's in degree.
|
|
2796
|
+
*
|
|
2797
|
+
* @param {any} node - The node's key.
|
|
2798
|
+
* @return {number} - The node's in degree.
|
|
2799
|
+
*
|
|
2800
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2801
|
+
*/
|
|
2802
|
+
inDegree(node) {
|
|
2803
|
+
node = "" + node;
|
|
2804
|
+
const nodeData = this._nodes.get(node);
|
|
2805
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.inDegree: could not find the "${node}" node in the graph.`);
|
|
2806
|
+
if (this.type === "undirected") return 0;
|
|
2807
|
+
return nodeData.inDegree;
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* Method returning the given node's out degree.
|
|
2811
|
+
*
|
|
2812
|
+
* @param {any} node - The node's key.
|
|
2813
|
+
* @return {number} - The node's in degree.
|
|
2814
|
+
*
|
|
2815
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2816
|
+
*/
|
|
2817
|
+
outDegree(node) {
|
|
2818
|
+
node = "" + node;
|
|
2819
|
+
const nodeData = this._nodes.get(node);
|
|
2820
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.outDegree: could not find the "${node}" node in the graph.`);
|
|
2821
|
+
if (this.type === "undirected") return 0;
|
|
2822
|
+
return nodeData.outDegree;
|
|
2823
|
+
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Method returning the given node's directed degree.
|
|
2826
|
+
*
|
|
2827
|
+
* @param {any} node - The node's key.
|
|
2828
|
+
* @return {number} - The node's in degree.
|
|
2829
|
+
*
|
|
2830
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2831
|
+
*/
|
|
2832
|
+
directedDegree(node) {
|
|
2833
|
+
node = "" + node;
|
|
2834
|
+
const nodeData = this._nodes.get(node);
|
|
2835
|
+
if (!nodeData)
|
|
2836
|
+
throw new NotFoundGraphError(`Graph.directedDegree: could not find the "${node}" node in the graph.`);
|
|
2837
|
+
if (this.type === "undirected") return 0;
|
|
2838
|
+
return nodeData.inDegree + nodeData.outDegree;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Method returning the given node's undirected degree.
|
|
2842
|
+
*
|
|
2843
|
+
* @param {any} node - The node's key.
|
|
2844
|
+
* @return {number} - The node's in degree.
|
|
2845
|
+
*
|
|
2846
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2847
|
+
*/
|
|
2848
|
+
undirectedDegree(node) {
|
|
2849
|
+
node = "" + node;
|
|
2850
|
+
const nodeData = this._nodes.get(node);
|
|
2851
|
+
if (!nodeData)
|
|
2852
|
+
throw new NotFoundGraphError(`Graph.undirectedDegree: could not find the "${node}" node in the graph.`);
|
|
2853
|
+
if (this.type === "directed") return 0;
|
|
2854
|
+
return nodeData.undirectedDegree;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Method returning the given node's inbound degree.
|
|
2858
|
+
*
|
|
2859
|
+
* @param {any} node - The node's key.
|
|
2860
|
+
* @return {number} - The node's inbound degree.
|
|
2861
|
+
*
|
|
2862
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2863
|
+
*/
|
|
2864
|
+
inboundDegree(node) {
|
|
2865
|
+
node = "" + node;
|
|
2866
|
+
const nodeData = this._nodes.get(node);
|
|
2867
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.inboundDegree: could not find the "${node}" node in the graph.`);
|
|
2868
|
+
let degree = 0;
|
|
2869
|
+
if (this.type !== "directed") {
|
|
2870
|
+
degree += nodeData.undirectedDegree;
|
|
2871
|
+
}
|
|
2872
|
+
if (this.type !== "undirected") {
|
|
2873
|
+
degree += nodeData.inDegree;
|
|
2874
|
+
}
|
|
2875
|
+
return degree;
|
|
2876
|
+
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Method returning the given node's outbound degree.
|
|
2879
|
+
*
|
|
2880
|
+
* @param {any} node - The node's key.
|
|
2881
|
+
* @return {number} - The node's outbound degree.
|
|
2882
|
+
*
|
|
2883
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2884
|
+
*/
|
|
2885
|
+
outboundDegree(node) {
|
|
2886
|
+
node = "" + node;
|
|
2887
|
+
const nodeData = this._nodes.get(node);
|
|
2888
|
+
if (!nodeData)
|
|
2889
|
+
throw new NotFoundGraphError(`Graph.outboundDegree: could not find the "${node}" node in the graph.`);
|
|
2890
|
+
let degree = 0;
|
|
2891
|
+
if (this.type !== "directed") {
|
|
2892
|
+
degree += nodeData.undirectedDegree;
|
|
2893
|
+
}
|
|
2894
|
+
if (this.type !== "undirected") {
|
|
2895
|
+
degree += nodeData.outDegree;
|
|
2896
|
+
}
|
|
2897
|
+
return degree;
|
|
2898
|
+
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Method returning the given node's directed degree.
|
|
2901
|
+
*
|
|
2902
|
+
* @param {any} node - The node's key.
|
|
2903
|
+
* @return {number} - The node's degree.
|
|
2904
|
+
*
|
|
2905
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2906
|
+
*/
|
|
2907
|
+
degree(node) {
|
|
2908
|
+
node = "" + node;
|
|
2909
|
+
const nodeData = this._nodes.get(node);
|
|
2910
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.degree: could not find the "${node}" node in the graph.`);
|
|
2911
|
+
let degree = 0;
|
|
2912
|
+
if (this.type !== "directed") {
|
|
2913
|
+
degree += nodeData.undirectedDegree;
|
|
2914
|
+
}
|
|
2915
|
+
if (this.type !== "undirected") {
|
|
2916
|
+
degree += nodeData.inDegree + nodeData.outDegree;
|
|
2917
|
+
}
|
|
2918
|
+
return degree;
|
|
2919
|
+
}
|
|
2920
|
+
/**
|
|
2921
|
+
* Method returning the given node's in degree without considering self loops.
|
|
2922
|
+
*
|
|
2923
|
+
* @param {any} node - The node's key.
|
|
2924
|
+
* @return {number} - The node's in degree.
|
|
2925
|
+
*
|
|
2926
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2927
|
+
*/
|
|
2928
|
+
inDegreeWithoutSelfLoops(node) {
|
|
2929
|
+
node = "" + node;
|
|
2930
|
+
const nodeData = this._nodes.get(node);
|
|
2931
|
+
if (!nodeData)
|
|
2932
|
+
throw new NotFoundGraphError(`Graph.inDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`);
|
|
2933
|
+
if (this.type === "undirected") return 0;
|
|
2934
|
+
return nodeData.inDegree - nodeData.directedLoops;
|
|
2935
|
+
}
|
|
2936
|
+
/**
|
|
2937
|
+
* Method returning the given node's out degree without considering self loops.
|
|
2938
|
+
*
|
|
2939
|
+
* @param {any} node - The node's key.
|
|
2940
|
+
* @return {number} - The node's in degree.
|
|
2941
|
+
*
|
|
2942
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2943
|
+
*/
|
|
2944
|
+
outDegreeWithoutSelfLoops(node) {
|
|
2945
|
+
node = "" + node;
|
|
2946
|
+
const nodeData = this._nodes.get(node);
|
|
2947
|
+
if (!nodeData)
|
|
2948
|
+
throw new NotFoundGraphError(`Graph.outDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`);
|
|
2949
|
+
if (this.type === "undirected") return 0;
|
|
2950
|
+
return nodeData.outDegree - nodeData.directedLoops;
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* Method returning the given node's directed degree without considering self loops.
|
|
2954
|
+
*
|
|
2955
|
+
* @param {any} node - The node's key.
|
|
2956
|
+
* @return {number} - The node's in degree.
|
|
2957
|
+
*
|
|
2958
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2959
|
+
*/
|
|
2960
|
+
directedDegreeWithoutSelfLoops(node) {
|
|
2961
|
+
node = "" + node;
|
|
2962
|
+
const nodeData = this._nodes.get(node);
|
|
2963
|
+
if (!nodeData)
|
|
2964
|
+
throw new NotFoundGraphError(
|
|
2965
|
+
`Graph.directedDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`,
|
|
2966
|
+
);
|
|
2967
|
+
if (this.type === "undirected") return 0;
|
|
2968
|
+
return nodeData.inDegree + nodeData.outDegree - nodeData.directedLoops * 2;
|
|
2969
|
+
}
|
|
2970
|
+
/**
|
|
2971
|
+
* Method returning the given node's undirected degree without considering self loops.
|
|
2972
|
+
*
|
|
2973
|
+
* @param {any} node - The node's key.
|
|
2974
|
+
* @return {number} - The node's in degree.
|
|
2975
|
+
*
|
|
2976
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2977
|
+
*/
|
|
2978
|
+
undirectedDegreeWithoutSelfLoops(node) {
|
|
2979
|
+
node = "" + node;
|
|
2980
|
+
const nodeData = this._nodes.get(node);
|
|
2981
|
+
if (!nodeData)
|
|
2982
|
+
throw new NotFoundGraphError(
|
|
2983
|
+
`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`,
|
|
2984
|
+
);
|
|
2985
|
+
if (this.type === "directed") return 0;
|
|
2986
|
+
return nodeData.undirectedDegree - nodeData.undirectedLoops * 2;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Method returning the given node's inbound degree without considering self loops.
|
|
2990
|
+
*
|
|
2991
|
+
* @param {any} node - The node's key.
|
|
2992
|
+
* @return {number} - The node's inbound degree.
|
|
2993
|
+
*
|
|
2994
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
2995
|
+
*/
|
|
2996
|
+
inboundDegreeWithoutSelfLoops(node) {
|
|
2997
|
+
node = "" + node;
|
|
2998
|
+
const nodeData = this._nodes.get(node);
|
|
2999
|
+
if (!nodeData)
|
|
3000
|
+
throw new NotFoundGraphError(
|
|
3001
|
+
`Graph.inboundDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`,
|
|
3002
|
+
);
|
|
3003
|
+
let degree = 0;
|
|
3004
|
+
let loops = 0;
|
|
3005
|
+
if (this.type !== "directed") {
|
|
3006
|
+
degree += nodeData.undirectedDegree;
|
|
3007
|
+
loops += nodeData.undirectedLoops * 2;
|
|
3008
|
+
}
|
|
3009
|
+
if (this.type !== "undirected") {
|
|
3010
|
+
degree += nodeData.inDegree;
|
|
3011
|
+
loops += nodeData.directedLoops;
|
|
3012
|
+
}
|
|
3013
|
+
return degree - loops;
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Method returning the given node's outbound degree without considering self loops.
|
|
3017
|
+
*
|
|
3018
|
+
* @param {any} node - The node's key.
|
|
3019
|
+
* @return {number} - The node's outbound degree.
|
|
3020
|
+
*
|
|
3021
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
3022
|
+
*/
|
|
3023
|
+
outboundDegreeWithoutSelfLoops(node) {
|
|
3024
|
+
node = "" + node;
|
|
3025
|
+
const nodeData = this._nodes.get(node);
|
|
3026
|
+
if (!nodeData)
|
|
3027
|
+
throw new NotFoundGraphError(
|
|
3028
|
+
`Graph.outboundDegreeWithoutSelfLoops: could not find the "${node}" node in the graph.`,
|
|
3029
|
+
);
|
|
3030
|
+
let degree = 0;
|
|
3031
|
+
let loops = 0;
|
|
3032
|
+
if (this.type !== "directed") {
|
|
3033
|
+
degree += nodeData.undirectedDegree;
|
|
3034
|
+
loops += nodeData.undirectedLoops * 2;
|
|
3035
|
+
}
|
|
3036
|
+
if (this.type !== "undirected") {
|
|
3037
|
+
degree += nodeData.outDegree;
|
|
3038
|
+
loops += nodeData.directedLoops;
|
|
3039
|
+
}
|
|
3040
|
+
return degree - loops;
|
|
3041
|
+
}
|
|
3042
|
+
/**
|
|
3043
|
+
* Method returning the given node's directed degree without considering self loops.
|
|
3044
|
+
*
|
|
3045
|
+
* @param {any} node - The node's key.
|
|
3046
|
+
* @return {number} - The node's degree.
|
|
3047
|
+
*
|
|
3048
|
+
* @throws {Error} - Will throw if the node isn't in the graph.
|
|
3049
|
+
*/
|
|
3050
|
+
degreeWithoutSelfLoops(node) {
|
|
3051
|
+
node = "" + node;
|
|
3052
|
+
const nodeData = this._nodes.get(node);
|
|
3053
|
+
if (!nodeData)
|
|
3054
|
+
throw new NotFoundGraphError(`Graph.degreeWithoutSelfLoops: could not find the "${node}" node in the graph.`);
|
|
3055
|
+
let degree = 0;
|
|
3056
|
+
let loops = 0;
|
|
3057
|
+
if (this.type !== "directed") {
|
|
3058
|
+
degree += nodeData.undirectedDegree;
|
|
3059
|
+
loops += nodeData.undirectedLoops * 2;
|
|
3060
|
+
}
|
|
3061
|
+
if (this.type !== "undirected") {
|
|
3062
|
+
degree += nodeData.inDegree + nodeData.outDegree;
|
|
3063
|
+
loops += nodeData.directedLoops * 2;
|
|
3064
|
+
}
|
|
3065
|
+
return degree - loops;
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Method returning the given edge's source.
|
|
3069
|
+
*
|
|
3070
|
+
* @param {any} edge - The edge's key.
|
|
3071
|
+
* @return {any} - The edge's source.
|
|
3072
|
+
*
|
|
3073
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3074
|
+
*/
|
|
3075
|
+
source(edge) {
|
|
3076
|
+
edge = "" + edge;
|
|
3077
|
+
const data = this._edges.get(edge);
|
|
3078
|
+
if (!data) throw new NotFoundGraphError(`Graph.source: could not find the "${edge}" edge in the graph.`);
|
|
3079
|
+
return data.source.key;
|
|
3080
|
+
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Method returning the given edge's target.
|
|
3083
|
+
*
|
|
3084
|
+
* @param {any} edge - The edge's key.
|
|
3085
|
+
* @return {any} - The edge's target.
|
|
3086
|
+
*
|
|
3087
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3088
|
+
*/
|
|
3089
|
+
target(edge) {
|
|
3090
|
+
edge = "" + edge;
|
|
3091
|
+
const data = this._edges.get(edge);
|
|
3092
|
+
if (!data) throw new NotFoundGraphError(`Graph.target: could not find the "${edge}" edge in the graph.`);
|
|
3093
|
+
return data.target.key;
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Method returning the given edge's extremities.
|
|
3097
|
+
*
|
|
3098
|
+
* @param {any} edge - The edge's key.
|
|
3099
|
+
* @return {array} - The edge's extremities.
|
|
3100
|
+
*
|
|
3101
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3102
|
+
*/
|
|
3103
|
+
extremities(edge) {
|
|
3104
|
+
edge = "" + edge;
|
|
3105
|
+
const edgeData = this._edges.get(edge);
|
|
3106
|
+
if (!edgeData) throw new NotFoundGraphError(`Graph.extremities: could not find the "${edge}" edge in the graph.`);
|
|
3107
|
+
return [edgeData.source.key, edgeData.target.key];
|
|
3108
|
+
}
|
|
3109
|
+
/**
|
|
3110
|
+
* Given a node & an edge, returns the other extremity of the edge.
|
|
3111
|
+
*
|
|
3112
|
+
* @param {any} node - The node's key.
|
|
3113
|
+
* @param {any} edge - The edge's key.
|
|
3114
|
+
* @return {any} - The related node.
|
|
3115
|
+
*
|
|
3116
|
+
* @throws {Error} - Will throw if the edge isn't in the graph or if the
|
|
3117
|
+
* edge & node are not related.
|
|
3118
|
+
*/
|
|
3119
|
+
opposite(node, edge) {
|
|
3120
|
+
node = "" + node;
|
|
3121
|
+
edge = "" + edge;
|
|
3122
|
+
const data = this._edges.get(edge);
|
|
3123
|
+
if (!data) throw new NotFoundGraphError(`Graph.opposite: could not find the "${edge}" edge in the graph.`);
|
|
3124
|
+
const source = data.source.key;
|
|
3125
|
+
const target = data.target.key;
|
|
3126
|
+
if (node === source) return target;
|
|
3127
|
+
if (node === target) return source;
|
|
3128
|
+
throw new NotFoundGraphError(
|
|
3129
|
+
`Graph.opposite: the "${node}" node is not attached to the "${edge}" edge (${source}, ${target}).`,
|
|
3130
|
+
);
|
|
3131
|
+
}
|
|
3132
|
+
/**
|
|
3133
|
+
* Returns whether the given edge has the given node as extremity.
|
|
3134
|
+
*
|
|
3135
|
+
* @param {any} edge - The edge's key.
|
|
3136
|
+
* @param {any} node - The node's key.
|
|
3137
|
+
* @return {boolean} - The related node.
|
|
3138
|
+
*
|
|
3139
|
+
* @throws {Error} - Will throw if either the node or the edge isn't in the graph.
|
|
3140
|
+
*/
|
|
3141
|
+
hasExtremity(edge, node) {
|
|
3142
|
+
edge = "" + edge;
|
|
3143
|
+
node = "" + node;
|
|
3144
|
+
const data = this._edges.get(edge);
|
|
3145
|
+
if (!data) throw new NotFoundGraphError(`Graph.hasExtremity: could not find the "${edge}" edge in the graph.`);
|
|
3146
|
+
return data.source.key === node || data.target.key === node;
|
|
3147
|
+
}
|
|
3148
|
+
/**
|
|
3149
|
+
* Method returning whether the given edge is undirected.
|
|
3150
|
+
*
|
|
3151
|
+
* @param {any} edge - The edge's key.
|
|
3152
|
+
* @return {boolean}
|
|
3153
|
+
*
|
|
3154
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3155
|
+
*/
|
|
3156
|
+
isUndirected(edge) {
|
|
3157
|
+
edge = "" + edge;
|
|
3158
|
+
const data = this._edges.get(edge);
|
|
3159
|
+
if (!data) throw new NotFoundGraphError(`Graph.isUndirected: could not find the "${edge}" edge in the graph.`);
|
|
3160
|
+
return data.undirected;
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Method returning whether the given edge is directed.
|
|
3164
|
+
*
|
|
3165
|
+
* @param {any} edge - The edge's key.
|
|
3166
|
+
* @return {boolean}
|
|
3167
|
+
*
|
|
3168
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3169
|
+
*/
|
|
3170
|
+
isDirected(edge) {
|
|
3171
|
+
edge = "" + edge;
|
|
3172
|
+
const data = this._edges.get(edge);
|
|
3173
|
+
if (!data) throw new NotFoundGraphError(`Graph.isDirected: could not find the "${edge}" edge in the graph.`);
|
|
3174
|
+
return !data.undirected;
|
|
3175
|
+
}
|
|
3176
|
+
/**
|
|
3177
|
+
* Method returning whether the given edge is a self loop.
|
|
3178
|
+
*
|
|
3179
|
+
* @param {any} edge - The edge's key.
|
|
3180
|
+
* @return {boolean}
|
|
3181
|
+
*
|
|
3182
|
+
* @throws {Error} - Will throw if the edge isn't in the graph.
|
|
3183
|
+
*/
|
|
3184
|
+
isSelfLoop(edge) {
|
|
3185
|
+
edge = "" + edge;
|
|
3186
|
+
const data = this._edges.get(edge);
|
|
3187
|
+
if (!data) throw new NotFoundGraphError(`Graph.isSelfLoop: could not find the "${edge}" edge in the graph.`);
|
|
3188
|
+
return data.source === data.target;
|
|
3189
|
+
}
|
|
3190
|
+
/**---------------------------------------------------------------------------
|
|
3191
|
+
* Mutation
|
|
3192
|
+
**---------------------------------------------------------------------------
|
|
3193
|
+
*/
|
|
3194
|
+
/**
|
|
3195
|
+
* Method used to add a node to the graph.
|
|
3196
|
+
*
|
|
3197
|
+
* @param {any} node - The node.
|
|
3198
|
+
* @param {object} [attributes] - Optional attributes.
|
|
3199
|
+
* @return {any} - The node.
|
|
3200
|
+
*
|
|
3201
|
+
* @throws {Error} - Will throw if the given node already exist.
|
|
3202
|
+
* @throws {Error} - Will throw if the given attributes are not an object.
|
|
3203
|
+
*/
|
|
3204
|
+
addNode(node, attributes) {
|
|
3205
|
+
const nodeData = addNode(this, node, attributes);
|
|
3206
|
+
return nodeData.key;
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Method used to merge a node into the graph.
|
|
3210
|
+
*
|
|
3211
|
+
* @param {any} node - The node.
|
|
3212
|
+
* @param {object} [attributes] - Optional attributes.
|
|
3213
|
+
* @return {any} - The node.
|
|
3214
|
+
*/
|
|
3215
|
+
mergeNode(node, attributes) {
|
|
3216
|
+
if (attributes && !isPlainObject(attributes))
|
|
3217
|
+
throw new InvalidArgumentsGraphError(
|
|
3218
|
+
`Graph.mergeNode: invalid attributes. Expecting an object but got "${attributes}"`,
|
|
3219
|
+
);
|
|
3220
|
+
node = "" + node;
|
|
3221
|
+
attributes = attributes || {};
|
|
3222
|
+
let data = this._nodes.get(node);
|
|
3223
|
+
if (data) {
|
|
3224
|
+
if (attributes) {
|
|
3225
|
+
assign(data.attributes, attributes);
|
|
3226
|
+
this.emit("nodeAttributesUpdated", {
|
|
3227
|
+
type: "merge",
|
|
3228
|
+
key: node,
|
|
3229
|
+
attributes: data.attributes,
|
|
3230
|
+
data: attributes,
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
return [node, false];
|
|
3234
|
+
}
|
|
3235
|
+
data = new this.NodeDataClass(node, attributes);
|
|
3236
|
+
this._nodes.set(node, data);
|
|
3237
|
+
this.emit("nodeAdded", {
|
|
3238
|
+
key: node,
|
|
3239
|
+
attributes,
|
|
3240
|
+
});
|
|
3241
|
+
return [node, true];
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Method used to add a node if it does not exist in the graph or else to
|
|
3245
|
+
* update its attributes using a function.
|
|
3246
|
+
*
|
|
3247
|
+
* @param {any} node - The node.
|
|
3248
|
+
* @param {function} [updater] - Optional updater function.
|
|
3249
|
+
* @return {any} - The node.
|
|
3250
|
+
*/
|
|
3251
|
+
updateNode(node, updater) {
|
|
3252
|
+
if (updater && typeof updater !== "function")
|
|
3253
|
+
throw new InvalidArgumentsGraphError(
|
|
3254
|
+
`Graph.updateNode: invalid updater function. Expecting a function but got "${updater}"`,
|
|
3255
|
+
);
|
|
3256
|
+
node = "" + node;
|
|
3257
|
+
let data = this._nodes.get(node);
|
|
3258
|
+
if (data) {
|
|
3259
|
+
if (updater) {
|
|
3260
|
+
const oldAttributes = data.attributes;
|
|
3261
|
+
data.attributes = updater(oldAttributes);
|
|
3262
|
+
this.emit("nodeAttributesUpdated", {
|
|
3263
|
+
type: "replace",
|
|
3264
|
+
key: node,
|
|
3265
|
+
attributes: data.attributes,
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
return [node, false];
|
|
3269
|
+
}
|
|
3270
|
+
const attributes = updater ? updater({}) : {};
|
|
3271
|
+
data = new this.NodeDataClass(node, attributes);
|
|
3272
|
+
this._nodes.set(node, data);
|
|
3273
|
+
this.emit("nodeAdded", {
|
|
3274
|
+
key: node,
|
|
3275
|
+
attributes,
|
|
3276
|
+
});
|
|
3277
|
+
return [node, true];
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Method used to drop a single node & all its attached edges from the graph.
|
|
3281
|
+
*
|
|
3282
|
+
* @param {any} node - The node.
|
|
3283
|
+
* @return {Graph}
|
|
3284
|
+
*
|
|
3285
|
+
* @throws {Error} - Will throw if the node doesn't exist.
|
|
3286
|
+
*/
|
|
3287
|
+
dropNode(node) {
|
|
3288
|
+
node = "" + node;
|
|
3289
|
+
const nodeData = this._nodes.get(node);
|
|
3290
|
+
if (!nodeData) throw new NotFoundGraphError(`Graph.dropNode: could not find the "${node}" node in the graph.`);
|
|
3291
|
+
let edgeData;
|
|
3292
|
+
if (this.type !== "undirected") {
|
|
3293
|
+
for (const neighbor in nodeData.out) {
|
|
3294
|
+
edgeData = nodeData.out[neighbor];
|
|
3295
|
+
do {
|
|
3296
|
+
dropEdgeFromData(this, edgeData);
|
|
3297
|
+
edgeData = edgeData.next;
|
|
3298
|
+
} while (edgeData);
|
|
3299
|
+
}
|
|
3300
|
+
for (const neighbor in nodeData.in) {
|
|
3301
|
+
edgeData = nodeData.in[neighbor];
|
|
3302
|
+
do {
|
|
3303
|
+
dropEdgeFromData(this, edgeData);
|
|
3304
|
+
edgeData = edgeData.next;
|
|
3305
|
+
} while (edgeData);
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
if (this.type !== "directed") {
|
|
3309
|
+
for (const neighbor in nodeData.undirected) {
|
|
3310
|
+
edgeData = nodeData.undirected[neighbor];
|
|
3311
|
+
do {
|
|
3312
|
+
dropEdgeFromData(this, edgeData);
|
|
3313
|
+
edgeData = edgeData.next;
|
|
3314
|
+
} while (edgeData);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
this._nodes.delete(node);
|
|
3318
|
+
this.emit("nodeDropped", {
|
|
3319
|
+
key: node,
|
|
3320
|
+
attributes: nodeData.attributes,
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Method used to drop a single edge from the graph.
|
|
3325
|
+
*
|
|
3326
|
+
* Arity 1:
|
|
3327
|
+
* @param {any} edge - The edge.
|
|
3328
|
+
*
|
|
3329
|
+
* Arity 2:
|
|
3330
|
+
* @param {any} source - Source node.
|
|
3331
|
+
* @param {any} target - Target node.
|
|
3332
|
+
*
|
|
3333
|
+
* @return {Graph}
|
|
3334
|
+
*
|
|
3335
|
+
* @throws {Error} - Will throw if the edge doesn't exist.
|
|
3336
|
+
*/
|
|
3337
|
+
dropEdge(edge) {
|
|
3338
|
+
let edgeData;
|
|
3339
|
+
if (arguments.length > 1) {
|
|
3340
|
+
const source = "" + arguments[0];
|
|
3341
|
+
const target = "" + arguments[1];
|
|
3342
|
+
edgeData = getMatchingEdge(this, source, target, this.type);
|
|
3343
|
+
if (!edgeData)
|
|
3344
|
+
throw new NotFoundGraphError(
|
|
3345
|
+
`Graph.dropEdge: could not find the "${source}" -> "${target}" edge in the graph.`,
|
|
3346
|
+
);
|
|
3347
|
+
} else {
|
|
3348
|
+
edge = "" + edge;
|
|
3349
|
+
edgeData = this._edges.get(edge);
|
|
3350
|
+
if (!edgeData) throw new NotFoundGraphError(`Graph.dropEdge: could not find the "${edge}" edge in the graph.`);
|
|
3351
|
+
}
|
|
3352
|
+
dropEdgeFromData(this, edgeData);
|
|
3353
|
+
return this;
|
|
3354
|
+
}
|
|
3355
|
+
/**
|
|
3356
|
+
* Method used to drop a single directed edge from the graph.
|
|
3357
|
+
*
|
|
3358
|
+
* @param {any} source - Source node.
|
|
3359
|
+
* @param {any} target - Target node.
|
|
3360
|
+
*
|
|
3361
|
+
* @return {Graph}
|
|
3362
|
+
*
|
|
3363
|
+
* @throws {Error} - Will throw if the edge doesn't exist.
|
|
3364
|
+
*/
|
|
3365
|
+
dropDirectedEdge(source, target) {
|
|
3366
|
+
if (arguments.length < 2)
|
|
3367
|
+
throw new UsageGraphError(
|
|
3368
|
+
"Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.",
|
|
3369
|
+
);
|
|
3370
|
+
if (this.multi)
|
|
3371
|
+
throw new UsageGraphError(
|
|
3372
|
+
"Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.",
|
|
3373
|
+
);
|
|
3374
|
+
source = "" + source;
|
|
3375
|
+
target = "" + target;
|
|
3376
|
+
const edgeData = getMatchingEdge(this, source, target, "directed");
|
|
3377
|
+
if (!edgeData)
|
|
3378
|
+
throw new NotFoundGraphError(
|
|
3379
|
+
`Graph.dropDirectedEdge: could not find a "${source}" -> "${target}" edge in the graph.`,
|
|
3380
|
+
);
|
|
3381
|
+
dropEdgeFromData(this, edgeData);
|
|
3382
|
+
return this;
|
|
3383
|
+
}
|
|
3384
|
+
/**
|
|
3385
|
+
* Method used to drop a single undirected edge from the graph.
|
|
3386
|
+
*
|
|
3387
|
+
* @param {any} source - Source node.
|
|
3388
|
+
* @param {any} target - Target node.
|
|
3389
|
+
*
|
|
3390
|
+
* @return {Graph}
|
|
3391
|
+
*
|
|
3392
|
+
* @throws {Error} - Will throw if the edge doesn't exist.
|
|
3393
|
+
*/
|
|
3394
|
+
dropUndirectedEdge(source, target) {
|
|
3395
|
+
if (arguments.length < 2)
|
|
3396
|
+
throw new UsageGraphError(
|
|
3397
|
+
"Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.",
|
|
3398
|
+
);
|
|
3399
|
+
if (this.multi)
|
|
3400
|
+
throw new UsageGraphError(
|
|
3401
|
+
"Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.",
|
|
3402
|
+
);
|
|
3403
|
+
const edgeData = getMatchingEdge(this, source, target, "undirected");
|
|
3404
|
+
if (!edgeData)
|
|
3405
|
+
throw new NotFoundGraphError(
|
|
3406
|
+
`Graph.dropUndirectedEdge: could not find a "${source}" -> "${target}" edge in the graph.`,
|
|
3407
|
+
);
|
|
3408
|
+
dropEdgeFromData(this, edgeData);
|
|
3409
|
+
return this;
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Method used to remove every edge & every node from the graph.
|
|
3413
|
+
*
|
|
3414
|
+
* @return {Graph}
|
|
3415
|
+
*/
|
|
3416
|
+
clear() {
|
|
3417
|
+
this._edges.clear();
|
|
3418
|
+
this._nodes.clear();
|
|
3419
|
+
this._resetInstanceCounters();
|
|
3420
|
+
this.emit("cleared");
|
|
3421
|
+
}
|
|
3422
|
+
/**
|
|
3423
|
+
* Method used to remove every edge from the graph.
|
|
3424
|
+
*
|
|
3425
|
+
* @return {Graph}
|
|
3426
|
+
*/
|
|
3427
|
+
clearEdges() {
|
|
3428
|
+
const iterator = this._nodes.values();
|
|
3429
|
+
let step;
|
|
3430
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3431
|
+
step.value.clear();
|
|
3432
|
+
}
|
|
3433
|
+
this._edges.clear();
|
|
3434
|
+
this._resetInstanceCounters();
|
|
3435
|
+
this.emit("edgesCleared");
|
|
3436
|
+
}
|
|
3437
|
+
/**---------------------------------------------------------------------------
|
|
3438
|
+
* Attributes-related methods
|
|
3439
|
+
**---------------------------------------------------------------------------
|
|
3440
|
+
*/
|
|
3441
|
+
/**
|
|
3442
|
+
* Method returning the desired graph's attribute.
|
|
3443
|
+
*
|
|
3444
|
+
* @param {string} name - Name of the attribute.
|
|
3445
|
+
* @return {any}
|
|
3446
|
+
*/
|
|
3447
|
+
getAttribute(name) {
|
|
3448
|
+
return this._attributes[name];
|
|
3449
|
+
}
|
|
3450
|
+
/**
|
|
3451
|
+
* Method returning the graph's attributes.
|
|
3452
|
+
*
|
|
3453
|
+
* @return {object}
|
|
3454
|
+
*/
|
|
3455
|
+
getAttributes() {
|
|
3456
|
+
return this._attributes;
|
|
3457
|
+
}
|
|
3458
|
+
/**
|
|
3459
|
+
* Method returning whether the graph has the desired attribute.
|
|
3460
|
+
*
|
|
3461
|
+
* @param {string} name - Name of the attribute.
|
|
3462
|
+
* @return {boolean}
|
|
3463
|
+
*/
|
|
3464
|
+
hasAttribute(name) {
|
|
3465
|
+
return this._attributes.hasOwnProperty(name);
|
|
3466
|
+
}
|
|
3467
|
+
/**
|
|
3468
|
+
* Method setting a value for the desired graph's attribute.
|
|
3469
|
+
*
|
|
3470
|
+
* @param {string} name - Name of the attribute.
|
|
3471
|
+
* @param {any} value - Value for the attribute.
|
|
3472
|
+
* @return {Graph}
|
|
3473
|
+
*/
|
|
3474
|
+
setAttribute(name, value) {
|
|
3475
|
+
this._attributes[name] = value;
|
|
3476
|
+
this.emit("attributesUpdated", {
|
|
3477
|
+
type: "set",
|
|
3478
|
+
attributes: this._attributes,
|
|
3479
|
+
name,
|
|
3480
|
+
});
|
|
3481
|
+
return this;
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Method using a function to update the desired graph's attribute's value.
|
|
3485
|
+
*
|
|
3486
|
+
* @param {string} name - Name of the attribute.
|
|
3487
|
+
* @param {function} updater - Function use to update the attribute's value.
|
|
3488
|
+
* @return {Graph}
|
|
3489
|
+
*/
|
|
3490
|
+
updateAttribute(name, updater) {
|
|
3491
|
+
if (typeof updater !== "function")
|
|
3492
|
+
throw new InvalidArgumentsGraphError("Graph.updateAttribute: updater should be a function.");
|
|
3493
|
+
const value = this._attributes[name];
|
|
3494
|
+
this._attributes[name] = updater(value);
|
|
3495
|
+
this.emit("attributesUpdated", {
|
|
3496
|
+
type: "set",
|
|
3497
|
+
attributes: this._attributes,
|
|
3498
|
+
name,
|
|
3499
|
+
});
|
|
3500
|
+
return this;
|
|
3501
|
+
}
|
|
3502
|
+
/**
|
|
3503
|
+
* Method removing the desired graph's attribute.
|
|
3504
|
+
*
|
|
3505
|
+
* @param {string} name - Name of the attribute.
|
|
3506
|
+
* @return {Graph}
|
|
3507
|
+
*/
|
|
3508
|
+
removeAttribute(name) {
|
|
3509
|
+
delete this._attributes[name];
|
|
3510
|
+
this.emit("attributesUpdated", {
|
|
3511
|
+
type: "remove",
|
|
3512
|
+
attributes: this._attributes,
|
|
3513
|
+
name,
|
|
3514
|
+
});
|
|
3515
|
+
return this;
|
|
3516
|
+
}
|
|
3517
|
+
/**
|
|
3518
|
+
* Method replacing the graph's attributes.
|
|
3519
|
+
*
|
|
3520
|
+
* @param {object} attributes - New attributes.
|
|
3521
|
+
* @return {Graph}
|
|
3522
|
+
*
|
|
3523
|
+
* @throws {Error} - Will throw if given attributes are not a plain object.
|
|
3524
|
+
*/
|
|
3525
|
+
replaceAttributes(attributes) {
|
|
3526
|
+
if (!isPlainObject(attributes))
|
|
3527
|
+
throw new InvalidArgumentsGraphError("Graph.replaceAttributes: provided attributes are not a plain object.");
|
|
3528
|
+
this._attributes = attributes;
|
|
3529
|
+
this.emit("attributesUpdated", {
|
|
3530
|
+
type: "replace",
|
|
3531
|
+
attributes: this._attributes,
|
|
3532
|
+
});
|
|
3533
|
+
return this;
|
|
3534
|
+
}
|
|
3535
|
+
/**
|
|
3536
|
+
* Method merging the graph's attributes.
|
|
3537
|
+
*
|
|
3538
|
+
* @param {object} attributes - Attributes to merge.
|
|
3539
|
+
* @return {Graph}
|
|
3540
|
+
*
|
|
3541
|
+
* @throws {Error} - Will throw if given attributes are not a plain object.
|
|
3542
|
+
*/
|
|
3543
|
+
mergeAttributes(attributes) {
|
|
3544
|
+
if (!isPlainObject(attributes))
|
|
3545
|
+
throw new InvalidArgumentsGraphError("Graph.mergeAttributes: provided attributes are not a plain object.");
|
|
3546
|
+
assign(this._attributes, attributes);
|
|
3547
|
+
this.emit("attributesUpdated", {
|
|
3548
|
+
type: "merge",
|
|
3549
|
+
attributes: this._attributes,
|
|
3550
|
+
data: attributes,
|
|
3551
|
+
});
|
|
3552
|
+
return this;
|
|
3553
|
+
}
|
|
3554
|
+
/**
|
|
3555
|
+
* Method updating the graph's attributes.
|
|
3556
|
+
*
|
|
3557
|
+
* @param {function} updater - Function used to update the attributes.
|
|
3558
|
+
* @return {Graph}
|
|
3559
|
+
*
|
|
3560
|
+
* @throws {Error} - Will throw if given updater is not a function.
|
|
3561
|
+
*/
|
|
3562
|
+
updateAttributes(updater) {
|
|
3563
|
+
if (typeof updater !== "function")
|
|
3564
|
+
throw new InvalidArgumentsGraphError("Graph.updateAttributes: provided updater is not a function.");
|
|
3565
|
+
this._attributes = updater(this._attributes);
|
|
3566
|
+
this.emit("attributesUpdated", {
|
|
3567
|
+
type: "update",
|
|
3568
|
+
attributes: this._attributes,
|
|
3569
|
+
});
|
|
3570
|
+
return this;
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* Method used to update each node's attributes using the given function.
|
|
3574
|
+
*
|
|
3575
|
+
* @param {function} updater - Updater function to use.
|
|
3576
|
+
* @param {object} [hints] - Optional hints.
|
|
3577
|
+
*/
|
|
3578
|
+
updateEachNodeAttributes(updater, hints) {
|
|
3579
|
+
if (typeof updater !== "function")
|
|
3580
|
+
throw new InvalidArgumentsGraphError("Graph.updateEachNodeAttributes: expecting an updater function.");
|
|
3581
|
+
if (hints && !validateHints(hints))
|
|
3582
|
+
throw new InvalidArgumentsGraphError(
|
|
3583
|
+
"Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}",
|
|
3584
|
+
);
|
|
3585
|
+
const iterator = this._nodes.values();
|
|
3586
|
+
let step, nodeData;
|
|
3587
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3588
|
+
nodeData = step.value;
|
|
3589
|
+
nodeData.attributes = updater(nodeData.key, nodeData.attributes);
|
|
3590
|
+
}
|
|
3591
|
+
this.emit("eachNodeAttributesUpdated", {
|
|
3592
|
+
hints: hints ? hints : null,
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
/**
|
|
3596
|
+
* Method used to update each edge's attributes using the given function.
|
|
3597
|
+
*
|
|
3598
|
+
* @param {function} updater - Updater function to use.
|
|
3599
|
+
* @param {object} [hints] - Optional hints.
|
|
3600
|
+
*/
|
|
3601
|
+
updateEachEdgeAttributes(updater, hints) {
|
|
3602
|
+
if (typeof updater !== "function")
|
|
3603
|
+
throw new InvalidArgumentsGraphError("Graph.updateEachEdgeAttributes: expecting an updater function.");
|
|
3604
|
+
if (hints && !validateHints(hints))
|
|
3605
|
+
throw new InvalidArgumentsGraphError(
|
|
3606
|
+
"Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}",
|
|
3607
|
+
);
|
|
3608
|
+
const iterator = this._edges.values();
|
|
3609
|
+
let step, edgeData, sourceData, targetData;
|
|
3610
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3611
|
+
edgeData = step.value;
|
|
3612
|
+
sourceData = edgeData.source;
|
|
3613
|
+
targetData = edgeData.target;
|
|
3614
|
+
edgeData.attributes = updater(
|
|
3615
|
+
edgeData.key,
|
|
3616
|
+
edgeData.attributes,
|
|
3617
|
+
sourceData.key,
|
|
3618
|
+
targetData.key,
|
|
3619
|
+
sourceData.attributes,
|
|
3620
|
+
targetData.attributes,
|
|
3621
|
+
edgeData.undirected,
|
|
3622
|
+
);
|
|
3623
|
+
}
|
|
3624
|
+
this.emit("eachEdgeAttributesUpdated", {
|
|
3625
|
+
hints: hints ? hints : null,
|
|
3626
|
+
});
|
|
3627
|
+
}
|
|
3628
|
+
/**---------------------------------------------------------------------------
|
|
3629
|
+
* Iteration-related methods
|
|
3630
|
+
**---------------------------------------------------------------------------
|
|
3631
|
+
*/
|
|
3632
|
+
/**
|
|
3633
|
+
* Method iterating over the graph's adjacency using the given callback.
|
|
3634
|
+
*
|
|
3635
|
+
* @param {function} callback - Callback to use.
|
|
3636
|
+
*/
|
|
3637
|
+
forEachAdjacencyEntry(callback) {
|
|
3638
|
+
if (typeof callback !== "function")
|
|
3639
|
+
throw new InvalidArgumentsGraphError("Graph.forEachAdjacencyEntry: expecting a callback.");
|
|
3640
|
+
forEachAdjacency(false, false, false, this, callback);
|
|
3641
|
+
}
|
|
3642
|
+
forEachAdjacencyEntryWithOrphans(callback) {
|
|
3643
|
+
if (typeof callback !== "function")
|
|
3644
|
+
throw new InvalidArgumentsGraphError("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");
|
|
3645
|
+
forEachAdjacency(false, false, true, this, callback);
|
|
3646
|
+
}
|
|
3647
|
+
/**
|
|
3648
|
+
* Method iterating over the graph's assymetric adjacency using the given callback.
|
|
3649
|
+
*
|
|
3650
|
+
* @param {function} callback - Callback to use.
|
|
3651
|
+
*/
|
|
3652
|
+
forEachAssymetricAdjacencyEntry(callback) {
|
|
3653
|
+
if (typeof callback !== "function")
|
|
3654
|
+
throw new InvalidArgumentsGraphError("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");
|
|
3655
|
+
forEachAdjacency(false, true, false, this, callback);
|
|
3656
|
+
}
|
|
3657
|
+
forEachAssymetricAdjacencyEntryWithOrphans(callback) {
|
|
3658
|
+
if (typeof callback !== "function")
|
|
3659
|
+
throw new InvalidArgumentsGraphError("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");
|
|
3660
|
+
forEachAdjacency(false, true, true, this, callback);
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* Method returning the list of the graph's nodes.
|
|
3664
|
+
*
|
|
3665
|
+
* @return {array} - The nodes.
|
|
3666
|
+
*/
|
|
3667
|
+
nodes() {
|
|
3668
|
+
return Array.from(this._nodes.keys());
|
|
3669
|
+
}
|
|
3670
|
+
/**
|
|
3671
|
+
* Method iterating over the graph's nodes using the given callback.
|
|
3672
|
+
*
|
|
3673
|
+
* @param {function} callback - Callback (key, attributes, index).
|
|
3674
|
+
*/
|
|
3675
|
+
forEachNode(callback) {
|
|
3676
|
+
if (typeof callback !== "function")
|
|
3677
|
+
throw new InvalidArgumentsGraphError("Graph.forEachNode: expecting a callback.");
|
|
3678
|
+
const iterator = this._nodes.values();
|
|
3679
|
+
let step, nodeData;
|
|
3680
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3681
|
+
nodeData = step.value;
|
|
3682
|
+
callback(nodeData.key, nodeData.attributes);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Method iterating attempting to find a node matching the given predicate
|
|
3687
|
+
* function.
|
|
3688
|
+
*
|
|
3689
|
+
* @param {function} callback - Callback (key, attributes).
|
|
3690
|
+
*/
|
|
3691
|
+
findNode(callback) {
|
|
3692
|
+
if (typeof callback !== "function") throw new InvalidArgumentsGraphError("Graph.findNode: expecting a callback.");
|
|
3693
|
+
const iterator = this._nodes.values();
|
|
3694
|
+
let step, nodeData;
|
|
3695
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3696
|
+
nodeData = step.value;
|
|
3697
|
+
if (callback(nodeData.key, nodeData.attributes)) return nodeData.key;
|
|
3698
|
+
}
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Method mapping nodes.
|
|
3703
|
+
*
|
|
3704
|
+
* @param {function} callback - Callback (key, attributes).
|
|
3705
|
+
*/
|
|
3706
|
+
mapNodes(callback) {
|
|
3707
|
+
if (typeof callback !== "function") throw new InvalidArgumentsGraphError("Graph.mapNode: expecting a callback.");
|
|
3708
|
+
const iterator = this._nodes.values();
|
|
3709
|
+
let step, nodeData;
|
|
3710
|
+
const result = new Array(this.order);
|
|
3711
|
+
let i = 0;
|
|
3712
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3713
|
+
nodeData = step.value;
|
|
3714
|
+
result[i++] = callback(nodeData.key, nodeData.attributes);
|
|
3715
|
+
}
|
|
3716
|
+
return result;
|
|
3717
|
+
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Method returning whether some node verify the given predicate.
|
|
3720
|
+
*
|
|
3721
|
+
* @param {function} callback - Callback (key, attributes).
|
|
3722
|
+
*/
|
|
3723
|
+
someNode(callback) {
|
|
3724
|
+
if (typeof callback !== "function") throw new InvalidArgumentsGraphError("Graph.someNode: expecting a callback.");
|
|
3725
|
+
const iterator = this._nodes.values();
|
|
3726
|
+
let step, nodeData;
|
|
3727
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3728
|
+
nodeData = step.value;
|
|
3729
|
+
if (callback(nodeData.key, nodeData.attributes)) return true;
|
|
3730
|
+
}
|
|
3731
|
+
return false;
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Method returning whether all node verify the given predicate.
|
|
3735
|
+
*
|
|
3736
|
+
* @param {function} callback - Callback (key, attributes).
|
|
3737
|
+
*/
|
|
3738
|
+
everyNode(callback) {
|
|
3739
|
+
if (typeof callback !== "function") throw new InvalidArgumentsGraphError("Graph.everyNode: expecting a callback.");
|
|
3740
|
+
const iterator = this._nodes.values();
|
|
3741
|
+
let step, nodeData;
|
|
3742
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3743
|
+
nodeData = step.value;
|
|
3744
|
+
if (!callback(nodeData.key, nodeData.attributes)) return false;
|
|
3745
|
+
}
|
|
3746
|
+
return true;
|
|
3747
|
+
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Method filtering nodes.
|
|
3750
|
+
*
|
|
3751
|
+
* @param {function} callback - Callback (key, attributes).
|
|
3752
|
+
*/
|
|
3753
|
+
filterNodes(callback) {
|
|
3754
|
+
if (typeof callback !== "function")
|
|
3755
|
+
throw new InvalidArgumentsGraphError("Graph.filterNodes: expecting a callback.");
|
|
3756
|
+
const iterator = this._nodes.values();
|
|
3757
|
+
let step, nodeData;
|
|
3758
|
+
const result = [];
|
|
3759
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3760
|
+
nodeData = step.value;
|
|
3761
|
+
if (callback(nodeData.key, nodeData.attributes)) result.push(nodeData.key);
|
|
3762
|
+
}
|
|
3763
|
+
return result;
|
|
3764
|
+
}
|
|
3765
|
+
/**
|
|
3766
|
+
* Method reducing nodes.
|
|
3767
|
+
*
|
|
3768
|
+
* @param {function} callback - Callback (accumulator, key, attributes).
|
|
3769
|
+
*/
|
|
3770
|
+
reduceNodes(callback, initialValue) {
|
|
3771
|
+
if (typeof callback !== "function")
|
|
3772
|
+
throw new InvalidArgumentsGraphError("Graph.reduceNodes: expecting a callback.");
|
|
3773
|
+
if (arguments.length < 2)
|
|
3774
|
+
throw new InvalidArgumentsGraphError(
|
|
3775
|
+
"Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.",
|
|
3776
|
+
);
|
|
3777
|
+
let accumulator = initialValue;
|
|
3778
|
+
const iterator = this._nodes.values();
|
|
3779
|
+
let step, nodeData;
|
|
3780
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3781
|
+
nodeData = step.value;
|
|
3782
|
+
accumulator = callback(accumulator, nodeData.key, nodeData.attributes);
|
|
3783
|
+
}
|
|
3784
|
+
return accumulator;
|
|
3785
|
+
}
|
|
3786
|
+
/**
|
|
3787
|
+
* Method returning an iterator over the graph's node entries.
|
|
3788
|
+
*
|
|
3789
|
+
* @return {Iterator}
|
|
3790
|
+
*/
|
|
3791
|
+
nodeEntries() {
|
|
3792
|
+
const iterator = this._nodes.values();
|
|
3793
|
+
return {
|
|
3794
|
+
[Symbol.iterator]() {
|
|
3795
|
+
return this;
|
|
3796
|
+
},
|
|
3797
|
+
next() {
|
|
3798
|
+
const step = iterator.next();
|
|
3799
|
+
if (step.done) return step;
|
|
3800
|
+
const data = step.value;
|
|
3801
|
+
return {
|
|
3802
|
+
value: { node: data.key, attributes: data.attributes },
|
|
3803
|
+
done: false,
|
|
3804
|
+
};
|
|
3805
|
+
},
|
|
3806
|
+
};
|
|
3807
|
+
}
|
|
3808
|
+
/**---------------------------------------------------------------------------
|
|
3809
|
+
* Serialization
|
|
3810
|
+
**---------------------------------------------------------------------------
|
|
3811
|
+
*/
|
|
3812
|
+
/**
|
|
3813
|
+
* Method used to export the whole graph.
|
|
3814
|
+
*
|
|
3815
|
+
* @return {object} - The serialized graph.
|
|
3816
|
+
*/
|
|
3817
|
+
export() {
|
|
3818
|
+
const nodes = new Array(this._nodes.size);
|
|
3819
|
+
let i = 0;
|
|
3820
|
+
this._nodes.forEach((data, key) => {
|
|
3821
|
+
nodes[i++] = serializeNode(key, data);
|
|
3822
|
+
});
|
|
3823
|
+
const edges = new Array(this._edges.size);
|
|
3824
|
+
i = 0;
|
|
3825
|
+
this._edges.forEach((data, key) => {
|
|
3826
|
+
edges[i++] = serializeEdge(this.type, key, data);
|
|
3827
|
+
});
|
|
3828
|
+
return {
|
|
3829
|
+
options: {
|
|
3830
|
+
type: this.type,
|
|
3831
|
+
multi: this.multi,
|
|
3832
|
+
allowSelfLoops: this.allowSelfLoops,
|
|
3833
|
+
},
|
|
3834
|
+
attributes: this.getAttributes(),
|
|
3835
|
+
nodes,
|
|
3836
|
+
edges,
|
|
3837
|
+
};
|
|
3838
|
+
}
|
|
3839
|
+
/**
|
|
3840
|
+
* Method used to import a serialized graph.
|
|
3841
|
+
*
|
|
3842
|
+
* @param {object|Graph} data - The serialized graph.
|
|
3843
|
+
* @param {boolean} merge - Whether to merge data.
|
|
3844
|
+
* @return {Graph} - Returns itself for chaining.
|
|
3845
|
+
*/
|
|
3846
|
+
import(data, merge = false) {
|
|
3847
|
+
if (data instanceof _Graph) {
|
|
3848
|
+
data.forEachNode((n, a) => {
|
|
3849
|
+
if (merge) this.mergeNode(n, a);
|
|
3850
|
+
else this.addNode(n, a);
|
|
3851
|
+
});
|
|
3852
|
+
data.forEachEdge((e, a, s, t, _sa, _ta, u) => {
|
|
3853
|
+
if (merge) {
|
|
3854
|
+
if (u) this.mergeUndirectedEdgeWithKey(e, s, t, a);
|
|
3855
|
+
else this.mergeDirectedEdgeWithKey(e, s, t, a);
|
|
3856
|
+
} else {
|
|
3857
|
+
if (u) this.addUndirectedEdgeWithKey(e, s, t, a);
|
|
3858
|
+
else this.addDirectedEdgeWithKey(e, s, t, a);
|
|
3859
|
+
}
|
|
3860
|
+
});
|
|
3861
|
+
return this;
|
|
3862
|
+
}
|
|
3863
|
+
if (!isPlainObject(data))
|
|
3864
|
+
throw new InvalidArgumentsGraphError(
|
|
3865
|
+
"Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.",
|
|
3866
|
+
);
|
|
3867
|
+
if (data.attributes) {
|
|
3868
|
+
if (!isPlainObject(data.attributes))
|
|
3869
|
+
throw new InvalidArgumentsGraphError("Graph.import: invalid attributes. Expecting a plain object.");
|
|
3870
|
+
if (merge) this.mergeAttributes(data.attributes);
|
|
3871
|
+
else this.replaceAttributes(data.attributes);
|
|
3872
|
+
}
|
|
3873
|
+
let i, l, list, node, edge;
|
|
3874
|
+
if (data.nodes) {
|
|
3875
|
+
list = data.nodes;
|
|
3876
|
+
if (!Array.isArray(list))
|
|
3877
|
+
throw new InvalidArgumentsGraphError("Graph.import: invalid nodes. Expecting an array.");
|
|
3878
|
+
for (i = 0, l = list.length; i < l; i++) {
|
|
3879
|
+
node = list[i];
|
|
3880
|
+
validateSerializedNode(node);
|
|
3881
|
+
const { key, attributes } = node;
|
|
3882
|
+
if (merge) this.mergeNode(key, attributes);
|
|
3883
|
+
else this.addNode(key, attributes);
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
if (data.edges) {
|
|
3887
|
+
let undirectedByDefault = false;
|
|
3888
|
+
if (this.type === "undirected") {
|
|
3889
|
+
undirectedByDefault = true;
|
|
3890
|
+
}
|
|
3891
|
+
list = data.edges;
|
|
3892
|
+
if (!Array.isArray(list))
|
|
3893
|
+
throw new InvalidArgumentsGraphError("Graph.import: invalid edges. Expecting an array.");
|
|
3894
|
+
for (i = 0, l = list.length; i < l; i++) {
|
|
3895
|
+
edge = list[i];
|
|
3896
|
+
validateSerializedEdge(edge);
|
|
3897
|
+
const { source, target, attributes, undirected = undirectedByDefault } = edge;
|
|
3898
|
+
let method;
|
|
3899
|
+
if ("key" in edge) {
|
|
3900
|
+
method = merge
|
|
3901
|
+
? undirected
|
|
3902
|
+
? this.mergeUndirectedEdgeWithKey
|
|
3903
|
+
: this.mergeDirectedEdgeWithKey
|
|
3904
|
+
: undirected
|
|
3905
|
+
? this.addUndirectedEdgeWithKey
|
|
3906
|
+
: this.addDirectedEdgeWithKey;
|
|
3907
|
+
method.call(this, edge.key, source, target, attributes);
|
|
3908
|
+
} else {
|
|
3909
|
+
method = merge
|
|
3910
|
+
? undirected
|
|
3911
|
+
? this.mergeUndirectedEdge
|
|
3912
|
+
: this.mergeDirectedEdge
|
|
3913
|
+
: undirected
|
|
3914
|
+
? this.addUndirectedEdge
|
|
3915
|
+
: this.addDirectedEdge;
|
|
3916
|
+
method.call(this, source, target, attributes);
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
return this;
|
|
3921
|
+
}
|
|
3922
|
+
/**---------------------------------------------------------------------------
|
|
3923
|
+
* Utils
|
|
3924
|
+
**---------------------------------------------------------------------------
|
|
3925
|
+
*/
|
|
3926
|
+
/**
|
|
3927
|
+
* Method returning a null copy of the graph, i.e. a graph without nodes
|
|
3928
|
+
* & edges but with the exact same options.
|
|
3929
|
+
*
|
|
3930
|
+
* @param {object} options - Options to merge with the current ones.
|
|
3931
|
+
* @return {Graph} - The null copy.
|
|
3932
|
+
*/
|
|
3933
|
+
nullCopy(options) {
|
|
3934
|
+
const graph = new _Graph(assign({}, this._options, options));
|
|
3935
|
+
graph.replaceAttributes(assign({}, this.getAttributes()));
|
|
3936
|
+
return graph;
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* Method returning an empty copy of the graph, i.e. a graph without edges but
|
|
3940
|
+
* with the exact same options.
|
|
3941
|
+
*
|
|
3942
|
+
* @param {object} options - Options to merge with the current ones.
|
|
3943
|
+
* @return {Graph} - The empty copy.
|
|
3944
|
+
*/
|
|
3945
|
+
emptyCopy(options) {
|
|
3946
|
+
const graph = this.nullCopy(options);
|
|
3947
|
+
this._nodes.forEach((nodeData, key) => {
|
|
3948
|
+
const attributes = assign({}, nodeData.attributes);
|
|
3949
|
+
nodeData = new graph.NodeDataClass(key, attributes);
|
|
3950
|
+
graph._nodes.set(key, nodeData);
|
|
3951
|
+
});
|
|
3952
|
+
return graph;
|
|
3953
|
+
}
|
|
3954
|
+
/**
|
|
3955
|
+
* Method returning an exact copy of the graph.
|
|
3956
|
+
*
|
|
3957
|
+
* @param {object} options - Upgrade options.
|
|
3958
|
+
* @return {Graph} - The copy.
|
|
3959
|
+
*/
|
|
3960
|
+
copy(options) {
|
|
3961
|
+
options = options || {};
|
|
3962
|
+
if (typeof options.type === "string" && options.type !== this.type && options.type !== "mixed")
|
|
3963
|
+
throw new UsageGraphError(
|
|
3964
|
+
`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${options.type}" because this would mean losing information about the current graph.`,
|
|
3965
|
+
);
|
|
3966
|
+
if (typeof options.multi === "boolean" && options.multi !== this.multi && options.multi !== true)
|
|
3967
|
+
throw new UsageGraphError(
|
|
3968
|
+
"Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.",
|
|
3969
|
+
);
|
|
3970
|
+
if (
|
|
3971
|
+
typeof options.allowSelfLoops === "boolean" &&
|
|
3972
|
+
options.allowSelfLoops !== this.allowSelfLoops &&
|
|
3973
|
+
options.allowSelfLoops !== true
|
|
3974
|
+
)
|
|
3975
|
+
throw new UsageGraphError(
|
|
3976
|
+
"Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.",
|
|
3977
|
+
);
|
|
3978
|
+
const graph = this.emptyCopy(options);
|
|
3979
|
+
const iterator = this._edges.values();
|
|
3980
|
+
let step, edgeData;
|
|
3981
|
+
while (((step = iterator.next()), step.done !== true)) {
|
|
3982
|
+
edgeData = step.value;
|
|
3983
|
+
addEdge(
|
|
3984
|
+
graph,
|
|
3985
|
+
"copy",
|
|
3986
|
+
false,
|
|
3987
|
+
edgeData.undirected,
|
|
3988
|
+
edgeData.key,
|
|
3989
|
+
edgeData.source.key,
|
|
3990
|
+
edgeData.target.key,
|
|
3991
|
+
assign({}, edgeData.attributes),
|
|
3992
|
+
);
|
|
3993
|
+
}
|
|
3994
|
+
return graph;
|
|
3995
|
+
}
|
|
3996
|
+
/**---------------------------------------------------------------------------
|
|
3997
|
+
* Known methods
|
|
3998
|
+
**---------------------------------------------------------------------------
|
|
3999
|
+
*/
|
|
4000
|
+
/**
|
|
4001
|
+
* Method used by JavaScript to perform JSON serialization.
|
|
4002
|
+
*
|
|
4003
|
+
* @return {object} - The serialized graph.
|
|
4004
|
+
*/
|
|
4005
|
+
toJSON() {
|
|
4006
|
+
return this.export();
|
|
4007
|
+
}
|
|
4008
|
+
/**
|
|
4009
|
+
* Method returning [object Graph].
|
|
4010
|
+
*/
|
|
4011
|
+
toString() {
|
|
4012
|
+
return "[object Graph]";
|
|
4013
|
+
}
|
|
4014
|
+
/**
|
|
4015
|
+
* Method used internally by node's console to display a custom object.
|
|
4016
|
+
*
|
|
4017
|
+
* @return {object} - Formatted object representation of the graph.
|
|
4018
|
+
*/
|
|
4019
|
+
inspect() {
|
|
4020
|
+
const nodes = {};
|
|
4021
|
+
this._nodes.forEach((data, key) => {
|
|
4022
|
+
nodes[key] = data.attributes;
|
|
4023
|
+
});
|
|
4024
|
+
const edges = {},
|
|
4025
|
+
multiIndex = {};
|
|
4026
|
+
this._edges.forEach((data, key) => {
|
|
4027
|
+
const direction = data.undirected ? "--" : "->";
|
|
4028
|
+
let label = "";
|
|
4029
|
+
let source = data.source.key;
|
|
4030
|
+
let target = data.target.key;
|
|
4031
|
+
let tmp;
|
|
4032
|
+
if (data.undirected && source > target) {
|
|
4033
|
+
tmp = source;
|
|
4034
|
+
source = target;
|
|
4035
|
+
target = tmp;
|
|
4036
|
+
}
|
|
4037
|
+
const desc = `(${source})${direction}(${target})`;
|
|
4038
|
+
if (!key.startsWith("geid_")) {
|
|
4039
|
+
label += `[${key}]: `;
|
|
4040
|
+
} else if (this.multi) {
|
|
4041
|
+
if (typeof multiIndex[desc] === "undefined") {
|
|
4042
|
+
multiIndex[desc] = 0;
|
|
4043
|
+
} else {
|
|
4044
|
+
multiIndex[desc]++;
|
|
4045
|
+
}
|
|
4046
|
+
label += `${multiIndex[desc]}. `;
|
|
4047
|
+
}
|
|
4048
|
+
label += desc;
|
|
4049
|
+
edges[label] = data.attributes;
|
|
4050
|
+
});
|
|
4051
|
+
const dummy = {};
|
|
4052
|
+
for (const k in this) {
|
|
4053
|
+
if (this.hasOwnProperty(k) && !EMITTER_PROPS.has(k) && typeof this[k] !== "function" && typeof k !== "symbol")
|
|
4054
|
+
dummy[k] = this[k];
|
|
4055
|
+
}
|
|
4056
|
+
dummy.attributes = this._attributes;
|
|
4057
|
+
dummy.nodes = nodes;
|
|
4058
|
+
dummy.edges = edges;
|
|
4059
|
+
privateProperty(dummy, "constructor", this.constructor);
|
|
4060
|
+
return dummy;
|
|
4061
|
+
}
|
|
4062
|
+
};
|
|
4063
|
+
if (typeof Symbol !== "undefined")
|
|
4064
|
+
Graph.prototype[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = Graph.prototype.inspect;
|
|
4065
|
+
EDGE_ADD_METHODS.forEach((method) => {
|
|
4066
|
+
["add", "merge", "update"].forEach((verb) => {
|
|
4067
|
+
const name = method.name(verb);
|
|
4068
|
+
const fn = verb === "add" ? addEdge : mergeEdge;
|
|
4069
|
+
if (method.generateKey) {
|
|
4070
|
+
Graph.prototype[name] = function (source, target, attributes) {
|
|
4071
|
+
return fn(
|
|
4072
|
+
this,
|
|
4073
|
+
name,
|
|
4074
|
+
true,
|
|
4075
|
+
(method.type || this.type) === "undirected",
|
|
4076
|
+
null,
|
|
4077
|
+
source,
|
|
4078
|
+
target,
|
|
4079
|
+
attributes,
|
|
4080
|
+
verb === "update",
|
|
4081
|
+
);
|
|
4082
|
+
};
|
|
4083
|
+
} else {
|
|
4084
|
+
Graph.prototype[name] = function (edge, source, target, attributes) {
|
|
4085
|
+
return fn(
|
|
4086
|
+
this,
|
|
4087
|
+
name,
|
|
4088
|
+
false,
|
|
4089
|
+
(method.type || this.type) === "undirected",
|
|
4090
|
+
edge,
|
|
4091
|
+
source,
|
|
4092
|
+
target,
|
|
4093
|
+
attributes,
|
|
4094
|
+
verb === "update",
|
|
4095
|
+
);
|
|
4096
|
+
};
|
|
4097
|
+
}
|
|
4098
|
+
});
|
|
4099
|
+
});
|
|
4100
|
+
attachNodeAttributesMethods(Graph);
|
|
4101
|
+
attachEdgeAttributesMethods(Graph);
|
|
4102
|
+
attachEdgeIterationMethods(Graph);
|
|
4103
|
+
attachNeighborIterationMethods(Graph);
|
|
4104
|
+
var DirectedGraph = class extends Graph {
|
|
4105
|
+
constructor(options) {
|
|
4106
|
+
const finalOptions = assign({ type: "directed" }, options);
|
|
4107
|
+
if ("multi" in finalOptions && finalOptions.multi !== false)
|
|
4108
|
+
throw new InvalidArgumentsGraphError(
|
|
4109
|
+
"DirectedGraph.from: inconsistent indication that the graph should be multi in given options!",
|
|
4110
|
+
);
|
|
4111
|
+
if (finalOptions.type !== "directed")
|
|
4112
|
+
throw new InvalidArgumentsGraphError(
|
|
4113
|
+
'DirectedGraph.from: inconsistent "' + finalOptions.type + '" type in given options!',
|
|
4114
|
+
);
|
|
4115
|
+
super(finalOptions);
|
|
4116
|
+
}
|
|
4117
|
+
};
|
|
4118
|
+
var UndirectedGraph = class extends Graph {
|
|
4119
|
+
constructor(options) {
|
|
4120
|
+
const finalOptions = assign({ type: "undirected" }, options);
|
|
4121
|
+
if ("multi" in finalOptions && finalOptions.multi !== false)
|
|
4122
|
+
throw new InvalidArgumentsGraphError(
|
|
4123
|
+
"UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!",
|
|
4124
|
+
);
|
|
4125
|
+
if (finalOptions.type !== "undirected")
|
|
4126
|
+
throw new InvalidArgumentsGraphError(
|
|
4127
|
+
'UndirectedGraph.from: inconsistent "' + finalOptions.type + '" type in given options!',
|
|
4128
|
+
);
|
|
4129
|
+
super(finalOptions);
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
var MultiGraph = class extends Graph {
|
|
4133
|
+
constructor(options) {
|
|
4134
|
+
const finalOptions = assign({ multi: true }, options);
|
|
4135
|
+
if ("multi" in finalOptions && finalOptions.multi !== true)
|
|
4136
|
+
throw new InvalidArgumentsGraphError(
|
|
4137
|
+
"MultiGraph.from: inconsistent indication that the graph should be simple in given options!",
|
|
4138
|
+
);
|
|
4139
|
+
super(finalOptions);
|
|
4140
|
+
}
|
|
4141
|
+
};
|
|
4142
|
+
var MultiDirectedGraph = class extends Graph {
|
|
4143
|
+
constructor(options) {
|
|
4144
|
+
const finalOptions = assign({ type: "directed", multi: true }, options);
|
|
4145
|
+
if ("multi" in finalOptions && finalOptions.multi !== true)
|
|
4146
|
+
throw new InvalidArgumentsGraphError(
|
|
4147
|
+
"MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!",
|
|
4148
|
+
);
|
|
4149
|
+
if (finalOptions.type !== "directed")
|
|
4150
|
+
throw new InvalidArgumentsGraphError(
|
|
4151
|
+
'MultiDirectedGraph.from: inconsistent "' + finalOptions.type + '" type in given options!',
|
|
4152
|
+
);
|
|
4153
|
+
super(finalOptions);
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4156
|
+
var MultiUndirectedGraph = class extends Graph {
|
|
4157
|
+
constructor(options) {
|
|
4158
|
+
const finalOptions = assign({ type: "undirected", multi: true }, options);
|
|
4159
|
+
if ("multi" in finalOptions && finalOptions.multi !== true)
|
|
4160
|
+
throw new InvalidArgumentsGraphError(
|
|
4161
|
+
"MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!",
|
|
4162
|
+
);
|
|
4163
|
+
if (finalOptions.type !== "undirected")
|
|
4164
|
+
throw new InvalidArgumentsGraphError(
|
|
4165
|
+
'MultiUndirectedGraph.from: inconsistent "' + finalOptions.type + '" type in given options!',
|
|
4166
|
+
);
|
|
4167
|
+
super(finalOptions);
|
|
4168
|
+
}
|
|
4169
|
+
};
|
|
4170
|
+
function attachStaticFromMethod(Class) {
|
|
4171
|
+
Class.from = function (data, options) {
|
|
4172
|
+
const finalOptions = assign({}, data.options, options);
|
|
4173
|
+
const instance = new Class(finalOptions);
|
|
4174
|
+
instance.import(data);
|
|
4175
|
+
return instance;
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
attachStaticFromMethod(Graph);
|
|
4179
|
+
attachStaticFromMethod(DirectedGraph);
|
|
4180
|
+
attachStaticFromMethod(UndirectedGraph);
|
|
4181
|
+
attachStaticFromMethod(MultiGraph);
|
|
4182
|
+
attachStaticFromMethod(MultiDirectedGraph);
|
|
4183
|
+
attachStaticFromMethod(MultiUndirectedGraph);
|
|
4184
|
+
Graph.Graph = Graph;
|
|
4185
|
+
Graph.DirectedGraph = DirectedGraph;
|
|
4186
|
+
Graph.UndirectedGraph = UndirectedGraph;
|
|
4187
|
+
Graph.MultiGraph = MultiGraph;
|
|
4188
|
+
Graph.MultiDirectedGraph = MultiDirectedGraph;
|
|
4189
|
+
Graph.MultiUndirectedGraph = MultiUndirectedGraph;
|
|
4190
|
+
Graph.InvalidArgumentsGraphError = InvalidArgumentsGraphError;
|
|
4191
|
+
Graph.NotFoundGraphError = NotFoundGraphError;
|
|
4192
|
+
Graph.UsageGraphError = UsageGraphError;
|
|
4193
|
+
export {
|
|
4194
|
+
DirectedGraph,
|
|
4195
|
+
Graph,
|
|
4196
|
+
InvalidArgumentsGraphError,
|
|
4197
|
+
MultiDirectedGraph,
|
|
4198
|
+
MultiGraph,
|
|
4199
|
+
MultiUndirectedGraph,
|
|
4200
|
+
NotFoundGraphError,
|
|
4201
|
+
UndirectedGraph,
|
|
4202
|
+
UsageGraphError,
|
|
4203
|
+
Graph as default,
|
|
4204
|
+
};
|