file-graph 0.12.0
Install from the command line:
Learn more about npm packages
$ npm install @diy0r/file-graph@0.12.0
Install via package.json:
"@diy0r/file-graph": "0.12.0"
About this version
file-graph is a library for working with graphs using a file-based storage system. It provides functionality for creating, updating, deleting, and searching for graph vertices and edges, as well as for performing traversal and pathfinding operations within the graph.
npm install file-graph
Alternatively, you can install it from the GitHub registry:
npm install @diy0r/file-graph
const graph = FileGraph('../graph.txt');
FileGraph
accepts a path where the graph data will be stored. The graph
object returned is an instance of the FileGraphAbstract
class, which provides methods for manipulating the graph. You can refer to the jsDoc documentation for more details.
After initializing the graph at the specified path, a file will be created where each line represents a vertex. It is recommended not to modify the file contents manually.
Example of a vertex record:
{
"id": "33ef29be-adaa-4509-b306-62a32db7310e", // UUID - unique identifier of the vertex
"data": { ... }, // The data associated with the vertex
"links": [] // List of UUIDs of vertices that this vertex is connected to
}
const data = { name: 'Diyor', city: 'New-York' };
const createdVertex = await graph.createVertex<typeof data>(data);
This method returns an instance of the created vertex.