JavaScript library for modeling directed graphs
graphmodel
is a library for modeling directed graphs, based loosely on the Visual Studio GraphModel API.
Installation
npm install graphmodel
Usage
; // create a graphconst graph = ; // define schemagraphschemaproperties; // add nodesconst sourceNode = graphnodes;const targetNode = graphnodes; // add linksconst link = graphlinks; // find targetsfor const target of sourceNode {} // find sourcesfor const source of targetNode {} // add data to nodes/links sourceNode;link;
Advanced Usage
; const fileSystem = ; // node categoriesconst file = fileSystemschemacategories;const folder = fileSystemschemacategories; // link categoriesconst child = fileSystemschemacategories;const symlink = fileSystemschemacategories; // propertiesconst name = fileSystemschemaproperties; // add the '/' directoryconst root = fileSystemnodes;root; // add the '/home' directoryconst home = fileSystemnodes;home;fileSystemlinks; // add the '/home/jdoe' directoryconst homedir = fileSystemnodes;homedir;fileSystemlinks; // add a '/home/jdoe/profile' fileconst profile = fileSystemnodes;profile;fileSystemlinks; // add a symbolic link from '/home/jdoe/profile' to '/home/jdoe/profile2'const profile2 = fileSystemnodes;profile2;fileSystemlinks;fileSystemlinks; // find all files beneath '/'const files = root; // find all containing folders of '/home/jdoe/profile'const folders = profile; // resolve symbolic link for '/home/jdoe/profile2'const target = profile2;
API Overview
- Graph
- GraphSchema
- GraphSchemaCollection
- GraphMetadataContainer
- GraphMetadata
- GraphCategory
- GraphCategoryCollection
- GraphProperty
- GraphPropertyCollection
- GraphObject
- GraphNode
- GraphNodeCollection
- GraphLink
- GraphLinkCollection
- GraphCommonSchema
License
Copyright 2017 Ron Buckton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.