Socket
Socket
Sign inDemoInstall

@antv/graphlib

Package Overview
Dependencies
Maintainers
64
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/graphlib - npm Package Compare versions

Comparing version 2.0.0-alpha.3 to 2.0.0

docs/classes/Graph.md

29

__tests__/graph.spec.ts

@@ -12,3 +12,3 @@ import { Graph } from '../src/index';

it('creates a Graph with options', () => {
const nodes =[
const nodes = [
{ id: 'Node1', data: {} },

@@ -52,2 +52,19 @@ { id: 'Node2', data: {} },

{
type: 'NodeDataUpdated',
id: 'B',
propertyName: 'foo',
oldValue: 1,
newValue: 2,
},
{
type: 'NodeDataUpdated',
id: 'B',
oldValue: {
foo: 2,
},
newValue: {
bar: 3,
},
},
{
type: 'EdgeDataUpdated',

@@ -76,2 +93,12 @@ id: 'A',

{
type: 'NodeDataUpdated',
id: 'B',
oldValue: {
foo: 2,
},
newValue: {
bar: 3,
},
},
{
type: 'EdgeDataUpdated',

@@ -78,0 +105,0 @@ id: 'A',

3

__tests__/graphView.spec.ts

@@ -33,4 +33,3 @@ import { ID } from '../src';

});
const graphView = new GraphView({
graph,
const graphView = graph.createView({
nodeFilter: (node) => node.data.visible,

@@ -37,0 +36,0 @@ edgeFilter: (edge) => edge.data.visible,

@@ -52,3 +52,3 @@ import { Graph } from '../src';

graph.setParent(4, 2);
expect(graph.getAncestors(5).map(n => n.id)).toEqual([4, 2, 1]);
expect(graph.getAncestors(5).map((n) => n.id)).toEqual([4, 2, 1]);
});

@@ -101,3 +101,3 @@

// dfs
graph.dfsTree(1, n => {
graph.dfsTree(1, (n) => {
ids.push(Number(n.id));

@@ -108,3 +108,3 @@ });

ids.length = 0;
graph.dfsTree(1, n => {
graph.dfsTree(1, (n) => {
ids.push(Number(n.id));

@@ -116,3 +116,3 @@ if (n.id === 4) return true;

ids.length = 0;
graph.bfsTree(1, n => {
graph.bfsTree(1, (n) => {
ids.push(Number(n.id));

@@ -123,3 +123,3 @@ });

ids.length = 0;
graph.bfsTree(1, n => {
graph.bfsTree(1, (n) => {
ids.push(Number(n.id));

@@ -126,0 +126,0 @@ if (n.id === 3) return true;

{
"name": "@antv/graphlib",
"version": "2.0.0-alpha.3",
"version": "2.0.0",
"sideEffects": false,
"scripts": {
"clean": "rimraf lib esm dist",
"doc": "typedoc src/index.ts --plugin typedoc-plugin-markdown",
"lint-staged": "lint-staged",

@@ -50,3 +51,4 @@ "lint": "eslint ./src ./__tests__ && prettier ./src ./__tests__ --check ",

"tslib": "^2.4.1",
"typedoc": "^0.23.22",
"typedoc": "^0.23.24",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "^4.9.4"

@@ -53,0 +55,0 @@ },

@@ -9,10 +9,9 @@ # Graphlib

## Content of Package
## Features
### Namespaces
- Manage graph structure data with simple APIs.
- Easily batch multiple changes for performance optimization.
- GraphView for efficient data transformation.
- [algorithm](docs/modules/algorithm.md)
- [comparision](docs/modules/comparision.md)
- [essence](docs/modules/essence.md)
- [generate](docs/modules/generate.md)
## API

@@ -22,24 +21,8 @@ ### Classes

- [Graph](docs/classes/Graph.md)
- [GraphWithEvent](docs/classes/GraphWithEvent.md)
- [GraphView](docs/classes/GraphView.md)
## Change Log
#### 1.2.0
#### 2.0
- 🎉 `GraphWithEvent` now you can use graph with event listener
- 🎉 `essece` module for graph basic essence property check
- 🎉 `generate` module for graph generate new graph, now support graph's complement;
-
#### 1.1.0
- 🎉 Now we have comparision module for graph comparing with nodes/edges/options even subgraph
- 💪 Add isGraph to check if a object is a "Graph", and add a self loop checking function
#### 1.0.1
- 🔨 Completes test and bring all to 100%
#### 1.0.0
- 🎉 Release new graphlib with graph and algorithm
- 🎉 Release new version
import EventEmitter from '@antv/event-emitter';
import { GraphView } from './graphView';
import {

@@ -14,2 +15,3 @@ Node,

TreeStructureChanged,
GraphViewOptions,
} from './types';

@@ -203,11 +205,20 @@ import { doBFS, doDFS } from './utils/traverse';

// 👆 Could be merged as { id: A, propertyName: 'foo', oldValue: 1, newValue: 3 }.
const existingChange = mergedChanges.find((pastChange) => {
const index = mergedChanges.findIndex((pastChange) => {
return (
pastChange.type === change.type &&
pastChange.id === change.id &&
pastChange.propertyName === change.propertyName
(change.propertyName === undefined ||
pastChange.propertyName === change.propertyName)
);
});
const existingChange = mergedChanges[index];
if (existingChange) {
(existingChange as NodeDataUpdated<N>).newValue = change.newValue;
if (change.propertyName !== undefined) {
// The incoming change is of the same property of existing change.
(existingChange as NodeDataUpdated<N>).newValue = change.newValue;
} else {
// The incoming change is a whole data override.
mergedChanges.splice(index, 1);
mergedChanges.push(change);
}
} else {

@@ -984,3 +995,4 @@ mergedChanges.push(change);

let parent: Node<N> | null;
while (parent = this.getParent(current.id, treeKey)) {
// eslint-disable-next-line no-cond-assign
while ((parent = this.getParent(current.id, treeKey))) {
ancestors.push(parent);

@@ -1131,2 +1143,11 @@ current = parent;

}
public createView(
options: Omit<GraphViewOptions<N, E>, 'graph'>,
): GraphView<N, E> {
return new GraphView({
graph: this,
...options,
});
}
}

@@ -127,3 +127,3 @@ import type { Graph } from './graph';

*
* You can call {@link Graph.mergeChanges} to merge them into a {@link GraphDiff}.
* You can call {@link Graph.reduceChanges} to reduce them.
*/

@@ -130,0 +130,0 @@ changes: GraphChange<N, E>[];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc