Releases: datavis-tech/graph-data-structure
Releases · datavis-tech/graph-data-structure
v4.3.0
What's Changed
- Fix build on Node.js v22 by @JesusTheHun in #102
- Upgrade deps by @curran in #103
- Add a test to make sure that the function
shouldFollow
receives all expected arguments by @JesusTheHun in #100 - Prevent data duplication with
serializeGraph
when using object nodes by @JesusTheHun in #101
Full Changelog: v4.2.0...v4.3.0
v4.2.0
What's Changed
- fix:
getEdgeProperties
may returnundefined
if the edge doesn't exists by @JesusTheHun in #94 - feat: add
props
to theshouldFollow
opts, which contain the edge properties by @JesusTheHun in #95 - Update README.md by @curran in #91
- Upgrade deps by @curran in #96
- fix: wrong types reference in
package.json
by @viceice in #98 - Upgrade deps by @curran in #99
Full Changelog: v4.0.0...v4.2.0
Release 4.1.0
What's Changed
- fix:
getEdgeProperties
may returnundefined
if the edge doesn't exists by @JesusTheHun in #94 - feat: add
props
to theshouldFollow
opts, which contain the edge properties by @JesusTheHun in #95 - Update README.md by @curran in #91
Full Changelog: v4.0.0...v4.1.0
v4.0.0
Many thanks to @JesusTheHun for massively refactoring the library and API in this major version!
The following details come from #81:
Breaking changes :
Graph
is now a class, so it is instantiated withnew Graph()
instead ofGraph()
.Graph.adjacent()
now returns aSet<Node>
orundefined
if the node is not found.Graph.nodes()
is no longer available. A propertynodes: Set<Node>
is now exposed.Graph.serialize()
is no longer available. A standalone functionserializeGraph
is available instead.Graph.deserialize()
is no longer available. A standalone functiondeserializeGraph
is available instead.Graph.hasCycle()
is no longer available. A standalone functionhasCycle
is available instead.- All algorithm methods (i.e.
graph.topologicalSort()
are no longer available. A standalone function is available for each of them. - The
shortestPath
algorithm now returns an object{ nodes: Node[], weight: number }
instead of an augmented array.
Internal changes :
- The project now uses a composition pattern. Closes #18
- Native data structure
Map
andSet
are used instead of records and arrays. Closes #27 - Nodes are now references by their instance instead of their
id
property. - The tests have been migrated to
vitest
in order to be able to write tests in TypeScript without troubles. - Additional tests for types input and output have been written.
- The library is now bundled using rollup. The current solution does not support the export of types coming from type-only files. In addition, both
.d.cts
and.d.mts
declaration files are now distributed.
Features :
- Nodes can now be anything, not just string. Closes #51, closes #38
- New functions
getNode
,getFirstNode
,findNodes
to help you retrieve node references when they are objects. - Edge can now have properties. Closes #80
- Algorithm
depthFirstSearch
now accepts a functionshouldFollow
as an option, to conditionally follow an edge. Graph
now accept 2 generics to define the type of the nodes and edge properties.- The graph types are inferred from
deserializeGraph()
and the serialization type carries the types with it.
const g = new Graph<{ id: string }, { type: string }>();
// Good ✅
g.addNode({ id: "abcdef" });
g.setEdgeProperties(source, target, { type: 'foo' });
// Bad ❌ TS Error
g.addNode({ id: 1 });
g.setEdgeProperties(source, target, { label: 'wrong prop name' });
const node = g.nodes();
// ^? { id: string }[]
const props = g.getEdgeProperties(source, target);
// ^? { type: string }
Migration
Serialization
-const serialized = Graph().serialize();
+const serialized = serializeGraph(graph);
-const graph = Graph().deserialize(serialized);
+const graph = deserializeGraph(serialized);
Algorithms
-const sorted = graph.topologicalSort();
+const sorted = topologicalSort(graph);
-const path = graph.shortestPath();
-const nodes = path;
-const weight = path.weight;
+const { nodes, weight } = shortestPath(graph);
What's Changed
- New major version proposal by @JesusTheHun in #81
- Wrap up details for new major version release by @JesusTheHun in #87
- fix: update README.md example for node by @amopitt in #77
- Upgrade dependencies, run prettier by @curran in #83
- Upgrade dependencies by @curran in #89
New Contributors
- @amopitt made their first contribution in #77
- @JesusTheHun made their first contribution in #81
Full Changelog: v3.5.0...v4.0.0