Skip to content

Releases: datavis-tech/graph-data-structure

v4.3.0

04 Dec 14:41
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.2.0...v4.3.0

v4.2.0

14 Nov 16:24
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.0.0...v4.2.0

Release 4.1.0

23 Oct 15:47
Compare
Choose a tag to compare

What's Changed

  • fix: getEdgeProperties may return undefined if the edge doesn't exists by @JesusTheHun in #94
  • feat: add props to the shouldFollow 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

12 Sep 10:27
Compare
Choose a tag to compare

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 with new Graph() instead of Graph().
  • Graph.adjacent() now returns a Set<Node> or undefined if the node is not found.
  • Graph.nodes() is no longer available. A property nodes: Set<Node> is now exposed.
  • Graph.serialize() is no longer available. A standalone function serializeGraph is available instead.
  • Graph.deserialize() is no longer available. A standalone function deserializeGraph is available instead.
  • Graph.hasCycle() is no longer available. A standalone function hasCycle 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 and Set 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 function shouldFollow 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 Contributors

Full Changelog: v3.5.0...v4.0.0

v3.5.0

06 Dec 16:29
Compare
Choose a tag to compare

What's Changed

Full Changelog: v3.4.0...v3.5.0

Release 3.4.0

03 Aug 16:28
Compare
Choose a tag to compare
  • Upgrade dependencies, prettier (3d1cce8)
  • Merge pull request #69 from krm35/feature/shortestPaths (9540161)
  • Add a shortestPaths function (ef9666b)

Release 3.3.0

03 Apr 08:56
Compare
Choose a tag to compare
  • Merge pull request #65 from flleonx/patch-1 (33fd6ed)
  • fix: exports order in package.json (1a08af8)

Export types, update dependencies

20 Feb 07:04
Compare
Choose a tag to compare

Many thanks to @sargunv for this contribution: #63

Release 3.1.1

29 Jan 02:04
Compare
Choose a tag to compare

Release 3.1.0

05 Jan 15:26
Compare
Choose a tag to compare

Many thanks to @viceice for moving microbundle to dev deps in #58!