@sandeepsj0000/react-graph-visualizer 1.0.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/README.md +646 -0
- package/dist/GraphVisualizer.d.ts +3 -0
- package/dist/exportUtils.d.ts +14 -0
- package/dist/graphEngine.d.ts +96 -0
- package/dist/index.cjs.js +5513 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +5503 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/useGraphEngine.d.ts +82 -0
- package/package.json +56 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { GraphData, GraphEdge, GraphNode, PathResult, NodeInfo, GraphStats, SubgraphResult } from "./types";
|
|
2
|
+
export declare class GraphEngine {
|
|
3
|
+
private adjacency;
|
|
4
|
+
private incomingAdjacency;
|
|
5
|
+
private directed;
|
|
6
|
+
private edges;
|
|
7
|
+
private nodes;
|
|
8
|
+
private labelMap;
|
|
9
|
+
private nodeMap;
|
|
10
|
+
constructor(data: GraphData);
|
|
11
|
+
/** Get display label for a node */
|
|
12
|
+
getLabel(id: string): string;
|
|
13
|
+
/** Get full node object by id */
|
|
14
|
+
getNode(id: string): GraphNode | undefined;
|
|
15
|
+
/** Get all node ids */
|
|
16
|
+
getNodeIds(): string[];
|
|
17
|
+
/** Get all nodes */
|
|
18
|
+
getNodes(): GraphNode[];
|
|
19
|
+
/** Get all edges */
|
|
20
|
+
getEdges(): GraphEdge[];
|
|
21
|
+
/** Check if a node exists */
|
|
22
|
+
hasNode(id: string): boolean;
|
|
23
|
+
/** Check if an edge exists between source and target */
|
|
24
|
+
hasEdge(source: string, target: string): boolean;
|
|
25
|
+
/** Get rich info about a node: label, degree, neighbors */
|
|
26
|
+
getNodeInfo(nodeId: string): NodeInfo | null;
|
|
27
|
+
/** Get all directly connected nodes (outgoing + incoming for directed, all for undirected) */
|
|
28
|
+
getConnectedNodes(nodeId: string): string[];
|
|
29
|
+
/** Get connected nodes with labels */
|
|
30
|
+
getConnectedNodesWithLabels(nodeId: string): {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
}[];
|
|
34
|
+
/** Get only outgoing neighbors (directed graphs) */
|
|
35
|
+
getOutgoingNeighbors(nodeId: string): string[];
|
|
36
|
+
/** Get only incoming neighbors (directed graphs) */
|
|
37
|
+
getIncomingNeighbors(nodeId: string): string[];
|
|
38
|
+
/** Out-degree of a node */
|
|
39
|
+
getOutDegree(nodeId: string): number;
|
|
40
|
+
/** In-degree of a node */
|
|
41
|
+
getInDegree(nodeId: string): number;
|
|
42
|
+
/** Total degree (unique neighbors count) */
|
|
43
|
+
getDegree(nodeId: string): number;
|
|
44
|
+
/** Get all nodes NOT connected to the given node */
|
|
45
|
+
getInvertedSelection(nodeId: string): string[];
|
|
46
|
+
/** Get inverted selection with labels */
|
|
47
|
+
getInvertedSelectionWithLabels(nodeId: string): {
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
}[];
|
|
51
|
+
/** Find all paths between two nodes using DFS (with cycle prevention and depth limit) */
|
|
52
|
+
findAllPaths(startId: string, endId: string, maxDepth?: number): PathResult[];
|
|
53
|
+
/** Find the shortest path between two nodes using BFS */
|
|
54
|
+
findShortestPath(startId: string, endId: string): PathResult | null;
|
|
55
|
+
/** Find all paths connecting multiple nodes (pairwise) */
|
|
56
|
+
findAllPathsBetweenMultiple(nodeIds: string[]): PathResult[];
|
|
57
|
+
/** Check if two nodes are reachable from each other */
|
|
58
|
+
areConnected(startId: string, endId: string): boolean;
|
|
59
|
+
/** Get all edges connected to a set of nodes (both endpoints in the set) */
|
|
60
|
+
getEdgesForNodes(nodeIds: Set<string>): GraphEdge[];
|
|
61
|
+
/** Get all edges touching a node (as source or target) */
|
|
62
|
+
getEdgesOfNode(nodeId: string): GraphEdge[];
|
|
63
|
+
/** Get edges on specific paths (returns set of "source->target" keys) */
|
|
64
|
+
getEdgesOnPaths(paths: PathResult[]): Set<string>;
|
|
65
|
+
/** Extract a subgraph containing only the specified nodes and edges between them */
|
|
66
|
+
getSubgraph(nodeIds: string[]): SubgraphResult;
|
|
67
|
+
/** Get the neighborhood subgraph: the node + all its direct neighbors + connecting edges */
|
|
68
|
+
getNeighborhoodSubgraph(nodeId: string): SubgraphResult;
|
|
69
|
+
/** Get summary stats about the graph */
|
|
70
|
+
getStats(): GraphStats;
|
|
71
|
+
/** Get nodes sorted by degree (descending) */
|
|
72
|
+
getNodesByDegree(): {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
degree: number;
|
|
76
|
+
}[];
|
|
77
|
+
/** Serialize a node list to CSV string */
|
|
78
|
+
static toCSV(nodes: {
|
|
79
|
+
id: string;
|
|
80
|
+
label: string;
|
|
81
|
+
}[]): string;
|
|
82
|
+
/** Serialize paths to CSV string */
|
|
83
|
+
static pathsToCSV(paths: PathResult[]): string;
|
|
84
|
+
/** Serialize a node list to JSON string */
|
|
85
|
+
static toJSON(nodes: {
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
88
|
+
}[]): string;
|
|
89
|
+
/** Serialize paths to JSON string */
|
|
90
|
+
static pathsToJSON(paths: PathResult[]): string;
|
|
91
|
+
/** Export the full graph data as JSON string */
|
|
92
|
+
toGraphJSON(): string;
|
|
93
|
+
isDirected(): boolean;
|
|
94
|
+
nodeCount(): number;
|
|
95
|
+
edgeCount(): number;
|
|
96
|
+
}
|