LiteGraph 2.0.9
See the version list below for details.
dotnet add package LiteGraph --version 2.0.9
NuGet\Install-Package LiteGraph -Version 2.0.9
<PackageReference Include="LiteGraph" Version="2.0.9" />
paket add LiteGraph --version 2.0.9
#r "nuget: LiteGraph, 2.0.9"
// Install LiteGraph as a Cake Addin #addin nuget:?package=LiteGraph&version=2.0.9 // Install LiteGraph as a Cake Tool #tool nuget:?package=LiteGraph&version=2.0.9
<img src="https://github.com/jchristn/LiteGraph/blob/main/assets/favicon.png" width="256" height="256">
LiteGraph
LiteGraph is a lightweight graph database built using Sqlite with support for exporting to GEXF.
New in v2.0.x
- Major overhaul, refactor, and breaking changes
- Integrated webserver and RESTful API
- Extensibility through base repository class
- Hierarchical expression support while filtering over graph, node, and edge data objects
- Removal of property constraints on nodes and edges
- Search APIs in the SDK for graphs, nodes, and edges
Bugs, Feedback, or Enhancement Requests
Please feel free to start an issue or a discussion!
Simple Example
Refer to the Test
project for a full example.
using LiteGraph;
LiteGraphClient graph = new LiteGraphClient(); // using Sqlite file litegraph.db
LiteGraphClient graph = new LiteGraphClient(
new SqliteRepository("mygraph.db")
); // use a specific file
// Create a graph
Graph graph = graph.CreateGraph(Guid.NewGuid(), "This is my graph!");
// Create nodes
Node node1 = graph.CreateNode(graph.GUID, new Node { Name = "node1" });
Node node2 = graph.CreateNode(graph.GUID, new Node { Name = "node2" });
Node node3 = graph.CreateNode(graph.GUID, new Node { Name = "node3" });
// Create edges
Edge edge1 = graph.CreateEdge(graph.GUID, node1.GUID, node2.GUID, "Node 1 to node 2");
Edge edge2 = graph.CreateEdge(graph.GUID, node2.GUID, node3.GUID, "Node 2 to node 3");
// Find routes
foreach (RouteDetail route in graph.GetRoutes(
SearchTypeEnum.DepthFirstSearch,
graph.GUID,
node1.GUID,
node2.GUID))
{
Console.WriteLine(...);
}
// Export to GEXF file
graph.ExportGraphToGexfFile(graph.GUID, "mygraph.gexf");
Working with Object Data
The Data
property can be attached to any Graph
, Node
, or Edge
object. The value must be serializable to JSON. This value is retrieved when reading objects, and filters can be created to retrieve only objects that have matches based on elements in the object stored in Data
. Refer to ExpressionTree for information on how to craft expressions.
using ExpressionTree;
class Person
{
public string Name { get; set; } = null;
public int Age { get; set; } = 0;
public string City { get; set; } = "San Jose";
}
Person person1 = new Person { Name = "Joel", Age = 47, City = "San Jose" };
graph.CreateNode(graph.GUID, new Node { Name = "Joel", Data = person1 });
Expr expr = new Expr
{
"Left": "City",
"Operator": "Equals",
"Right": "San Jose"
};
foreach (Node node in graph.ReadNodes(graph.GUID, expr))
{
Console.WriteLine(...);
}
REST API
LiteGraph includes a project called LiteGraph.Server
which allows you to deploy a RESTful front-end for LiteGraph. Refer to REST_API.md
and also the Postman collection in the root of this repository for details. By default, LiteGraph.Server listens on http://localhost:8701
and is only accessible to localhost
. Modify the litegraph.json
file to change settings including hostname and port.
$ cd LiteGraph.Server/bin/Debug/net8.0
$ dotnet LiteGraph.Server.dll
_ _ _ _
| (_) |_ ___ __ _ _ _ __ _ _ __| |_
| | | _/ -_) _` | '_/ _` | '_ \ ' \
|_|_|\__\___\__, |_| \__,_| .__/_||_|
|___/ |_|
LiteGraph Server
(c)2024 Joel Christner
Using settings file './litegraph.json'
Settings file './litegraph.json' does not exist, creating
Initializing logging
| syslog://127.0.0.1:514
2024-07-17 20:56:13 INSPIRON-14 1 Debug [LiteGraphServer] logging initialized
2024-07-17 20:56:13 INSPIRON-14 1 Debug [RestServiceHandler] starting REST server on http://localhost:8701/
Important!
| Configured to listen on localhost; LiteGraph will not be externally accessible
| Modify ./litegraph.json to change the REST listener hostname
2024-07-17 20:56:13 INSPIRON-14 1 Info [LiteGraphServer] starting at 7/17/2024 8:56:13 PM using process ID 3256
Running in Docker
A Docker image is available in Docker Hub under jchristn/litegraph:v2.0.7
. Use the Docker Compose start (compose-up.sh
and compose-up.bat
) and stop (compose-down.sh
and compose-down.bat
) scripts in the Docker
directory if you wish to run within Docker Compose. Ensure that you have a valid database file (e.g. litegraph.db
) and configuration file (e.g. litegraph.json
) exposed into your container.
Version History
Please refer to CHANGELOG.md
for version history.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Caching (>= 3.1.1)
- ExpressionTree (>= 1.0.2)
- Microsoft.Data.Sqlite (>= 8.0.7)
- Microsoft.Data.Sqlite.Core (>= 8.0.7)
- SyslogLogging (>= 2.0.2)
- Timestamps (>= 1.0.9)
-
net7.0
- Caching (>= 3.1.1)
- ExpressionTree (>= 1.0.2)
- Microsoft.Data.Sqlite (>= 8.0.7)
- Microsoft.Data.Sqlite.Core (>= 8.0.7)
- SyslogLogging (>= 2.0.2)
- Timestamps (>= 1.0.9)
-
net8.0
- Caching (>= 3.1.1)
- ExpressionTree (>= 1.0.2)
- Microsoft.Data.Sqlite (>= 8.0.7)
- Microsoft.Data.Sqlite.Core (>= 8.0.7)
- SyslogLogging (>= 2.0.2)
- Timestamps (>= 1.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 67 | 11/2/2024 |
2.0.16 | 147 | 8/15/2024 |
2.0.15 | 117 | 8/15/2024 |
2.0.13 | 121 | 8/14/2024 |
2.0.12 | 120 | 8/13/2024 |
2.0.10 | 110 | 8/9/2024 |
2.0.9 | 114 | 8/8/2024 |
2.0.8 | 111 | 8/8/2024 |
2.0.7 | 88 | 8/7/2024 |
2.0.2 | 100 | 7/18/2024 |
2.0.1 | 95 | 7/18/2024 |
2.0.0 | 100 | 7/17/2024 |
1.0.0.4 | 8,300 | 8/11/2022 |
1.0.0.3 | 707 | 4/1/2022 |
1.0.0.2 | 1,138 | 11/14/2021 |
1.0.0.1 | 8,908 | 1/20/2021 |
Major refactor and breaking changes