Convert Figma logo to code with AI

hypermodeinc logodgraph

high-performance graph database for real-time use cases

20,593
1,503
20,593
30

Top Related Projects

20,588

high-performance graph database for real-time use cases

13,689

Graphs for Everyone

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.

13,643

🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.

JanusGraph: an open-source, distributed graph database

Apache TinkerPop - a graph computing framework

Quick Overview

Hypermode's dgraph is a Python library for building and manipulating directed graphs. It provides a simple and intuitive API for creating, modifying, and analyzing graph structures, making it useful for various applications such as network analysis, data modeling, and algorithm implementation.

Pros

  • Easy-to-use API for graph operations
  • Supports both directed and undirected graphs
  • Efficient memory usage for large graphs
  • Includes basic graph algorithms and traversal methods

Cons

  • Limited advanced graph algorithms compared to some other libraries
  • Documentation could be more comprehensive
  • May not be as performant as some specialized graph libraries for very large-scale graphs
  • Lacks built-in visualization tools

Code Examples

Creating a simple directed graph:

from dgraph import Graph

g = Graph()
g.add_edge("A", "B")
g.add_edge("B", "C")
g.add_edge("A", "C")

print(g.nodes())  # Output: ['A', 'B', 'C']
print(g.edges())  # Output: [('A', 'B'), ('B', 'C'), ('A', 'C')]

Performing a depth-first search:

from dgraph import Graph

g = Graph()
g.add_edge("A", "B")
g.add_edge("B", "C")
g.add_edge("A", "D")

dfs_result = g.dfs("A")
print(dfs_result)  # Output: ['A', 'B', 'C', 'D']

Checking for a path between nodes:

from dgraph import Graph

g = Graph()
g.add_edge("X", "Y")
g.add_edge("Y", "Z")

has_path = g.has_path("X", "Z")
print(has_path)  # Output: True

Getting Started

To get started with dgraph, first install it using pip:

pip install dgraph

Then, you can create and manipulate graphs in your Python code:

from dgraph import Graph

# Create a new graph
g = Graph()

# Add some edges
g.add_edge("Node1", "Node2")
g.add_edge("Node2", "Node3")
g.add_edge("Node1", "Node3")

# Print graph information
print(g.nodes())
print(g.edges())

# Perform a breadth-first search
bfs_result = g.bfs("Node1")
print(bfs_result)

This example creates a simple graph, adds some edges, and performs a basic breadth-first search. You can explore more features and algorithms provided by dgraph in the library's documentation.

Competitor Comparisons

20,588

high-performance graph database for real-time use cases

Pros of dgraph

  • More active development with recent commits
  • Larger community and contributor base
  • Better documentation and examples

Cons of dgraph

  • Potentially more complex due to additional features
  • May have a steeper learning curve for beginners
  • Larger codebase to maintain and update

Code Comparison

dgraph:

func (n *node) BatchSet(ctx context.Context, kvs []*bpb.KV) error {
    if len(kvs) == 0 {
        return nil
    }
    return n.store.WriteBatch(kvs)
}

dgraph>:

func (n *node) BatchSet(ctx context.Context, kvs []*pb.KV) error {
    if len(kvs) == 0 {
        return nil
    }
    return n.store.WriteBatch(kvs)
}

The code snippets show similar functionality for batch setting key-value pairs. The main difference is in the import path for the protobuf package (bpb vs pb), suggesting slightly different project structures or dependencies.

Both repositories appear to be related to graph database implementations, with dgraph being the more established and actively maintained project. The dgraph> repository might be a fork or an experimental version with potential modifications or improvements. Users should consider their specific requirements and the level of community support when choosing between the two.

13,689

Graphs for Everyone

Pros of Neo4j

  • Mature and widely adopted graph database with extensive documentation and community support
  • Powerful Cypher query language for complex graph traversals and pattern matching
  • Built-in visualization tools for exploring graph data

Cons of Neo4j

  • Can be resource-intensive for large-scale deployments
  • Steeper learning curve for developers new to graph databases
  • Limited horizontal scalability compared to distributed graph databases

Code Comparison

Neo4j (Cypher query):

MATCH (p:Person)-[:KNOWS]->(f:Person)
WHERE p.name = "Alice"
RETURN f.name

DGraph (GraphQL+-):

{
  person(func: eq(name, "Alice")) {
    name
    knows {
      name
    }
  }
}

Both examples demonstrate querying for a person named "Alice" and returning the names of people they know. Neo4j uses the Cypher query language, while DGraph uses GraphQL+- for querying. The syntax differs, but both achieve similar results in terms of graph traversal and data retrieval.

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.

Pros of OrientDB

  • Multi-model database supporting graph, document, key/value, and object models
  • SQL-like query language for complex queries across different data models
  • Built-in support for multi-master replication and sharding

Cons of OrientDB

  • Steeper learning curve due to multiple data models and complex query language
  • Less focus on distributed graph processing compared to Dgraph
  • Smaller community and ecosystem compared to more specialized graph databases

Code Comparison

OrientDB query example:

SELECT FROM Person
WHERE name = 'John'
AND out('Friend').name CONTAINS 'Alice'

Dgraph query example:

{
  person(func: eq(name, "John")) @filter(has(friend)) {
    name
    friend @filter(eq(name, "Alice")) {
      name
    }
  }
}

Both databases offer query languages for graph operations, but OrientDB's SQL-like syntax may be more familiar to some developers, while Dgraph's GraphQL-like syntax is more aligned with modern graph query languages.

13,643

🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.

Pros of ArangoDB

  • Multi-model database supporting key/value, document, and graph data models
  • Powerful query language (AQL) for complex data operations
  • Built-in full-text search capabilities

Cons of ArangoDB

  • Steeper learning curve due to its multi-model nature
  • Less focus on distributed systems compared to Dgraph
  • Potentially higher resource consumption for smaller datasets

Code Comparison

ArangoDB query example:

FOR user IN users
  FILTER user.age > 30
  RETURN user.name

Dgraph query example:

{
  users(func: gt(age, 30)) {
    name
  }
}

Both databases offer powerful query languages, but ArangoDB's AQL is more SQL-like, while Dgraph uses a GraphQL-inspired syntax. ArangoDB's multi-model approach allows for more flexible data modeling, while Dgraph focuses on graph-native operations and scalability.

ArangoDB excels in scenarios requiring multiple data models and complex queries, while Dgraph is optimized for large-scale graph data and distributed systems. The choice between them depends on specific project requirements, data structure, and scalability needs.

JanusGraph: an open-source, distributed graph database

Pros of JanusGraph

  • Supports multiple storage backends (e.g., Apache Cassandra, HBase, Google Cloud Bigtable)
  • Integrates well with Apache TinkerPop ecosystem
  • Offers advanced indexing capabilities for complex graph queries

Cons of JanusGraph

  • Can be more complex to set up and configure compared to Dgraph
  • May have slower write performance for large-scale graph operations
  • Lacks built-in GraphQL support, which Dgraph provides out of the box

Code Comparison

JanusGraph example:

GraphTraversalSource g = graph.traversal();
Vertex v1 = g.addV("person").property("name", "Alice").next();
Vertex v2 = g.addV("person").property("name", "Bob").next();
g.addE("knows").from(v1).to(v2).property("since", 2010).next();

Dgraph example:

mutation := &api.Mutation{
    SetNquads: []byte(`
        _:alice <name> "Alice" .
        _:bob <name> "Bob" .
        _:alice <knows> _:bob (since=2010) .
    `),
}
txn.Mutate(context.Background(), mutation)

Both examples demonstrate adding vertices (nodes) and edges to the graph, but Dgraph uses a more concise RDF-like syntax for mutations.

Apache TinkerPop - a graph computing framework

Pros of TinkerPop

  • Mature and widely adopted graph computing framework with a large community
  • Supports multiple graph databases and query languages
  • Provides a comprehensive suite of graph computing tools and algorithms

Cons of TinkerPop

  • Steeper learning curve due to its extensive feature set
  • Can be more complex to set up and configure for specific use cases
  • May have higher overhead for simpler graph operations

Code Comparison

TinkerPop (Gremlin):

g.V().hasLabel('person').
  has('name', 'John').
  out('knows').
  values('name')

Dgraph:

{
  people(func: eq(name, "John")) {
    name
    knows {
      name
    }
  }
}

Both examples show querying for a person named John and retrieving the names of people they know. TinkerPop uses Gremlin, a graph traversal language, while Dgraph uses GraphQL+-. Dgraph's syntax is more declarative and may be easier for developers familiar with GraphQL, while TinkerPop's Gremlin offers more flexibility for complex traversals.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Dgraph Logo

The Only Native GraphQL Database With A Graph Backend.

Wiki ci-dgraph-tests ci-dgraph-load-tests ci-golang-lint ci-aqua-security-trivy-tests Coverage Status Go Report Card TODOs

Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It provides ACID transactions, consistent replication, and linearizable reads. It's built from the ground up to perform a rich set of queries. Being a native GraphQL database, it tightly controls how the data is arranged on disk to optimize for query performance and throughput, reducing disk seeks and network calls in a cluster.

Dgraph's goal is to provide Google production-level scale and throughput, with low enough latency to serve real-time user queries over terabytes of structured data. Dgraph supports GraphQL query syntax, and responds in JSON and Protocol Buffers over GRPC and HTTP. Dgraph is written using the Go Programming Language.

Status

Dgraph is at version v24.0.5 and is production-ready. Apart from the vast open source community, it is being used in production at multiple Fortune 500 companies, and by Intuit Katlas and VMware Purser. A hosted version of Dgraph is available at https://cloud.dgraph.io.

Supported Platforms

Dgraph officially supports the Linux/amd64 architecture. Support for Linux/arm64 is in development. In order to take advantage of memory performance gains and other architecture-specific advancements in Linux, we dropped official support Mac and Windows in 2021, see this blog post for more information. You can still build and use Dgraph on other platforms (for live or bulk loading for instance), but support for platforms other than Linux/amd64 is not available.

Running Dgraph in a Docker environment is the recommended testing and deployment method.

Install with Docker

If you're using Docker, you can use the official Dgraph image.

docker pull dgraph/dgraph:latest

For more information on a variety Docker deployment methods including Docker Compose and Kubernetes, see the docs.

Run a Quick Standalone Cluster

docker run -it -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph dgraph/standalone:latest

Install from Source

If you want to install from source, install Go 1.19+ or later and the following dependencies:

Ubuntu

sudo apt-get update
sudo apt-get install build-essential

Build and Install

Then clone the Dgraph repository and use make install to install the Dgraph binary in the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.

git clone https://github.com/hypermodeinc/dgraph.git
cd dgraph
make install

Get Started

To get started with Dgraph, follow:

Is Dgraph the right choice for me?

  • Do you have more than 10 SQL tables connected via foreign keys?
  • Do you have sparse data, which doesn't elegantly fit into SQL tables?
  • Do you want a simple and flexible schema, which is readable and maintainable over time?
  • Do you care about speed and performance at scale?

If the answers to the above are YES, then Dgraph would be a great fit for your application. Dgraph provides NoSQL like scalability while providing SQL like transactions and the ability to select, filter, and aggregate data points. It combines that with distributed joins, traversals, and graph operations, which makes it easy to build applications with it.

Dgraph compared to other graph DBs

FeaturesDgraphNeo4jJanus Graph
ArchitectureSharded and DistributedSingle server (+ replicas in enterprise)Layer on top of other distributed DBs
ReplicationConsistentNone in community edition (only available in enterprise)Via underlying DB
Data movement for shard rebalancingAutomaticNot applicable (all data lies on each server)Via underlying DB
LanguageGraphQL inspiredCypher, GremlinGremlin
ProtocolsGrpc / HTTP + JSON / RDFBolt + CypherWebsocket / HTTP
TransactionsDistributed ACID transactionsSingle server ACID transactionsNot typically ACID
Full-Text SearchNative supportNative supportVia External Indexing System
Regular ExpressionsNative supportNative supportVia External Indexing System
Geo SearchNative supportExternal support onlyVia External Indexing System
LicenseApache 2.0GPL v3Apache 2.0

Users

Developers

Client Libraries

The Dgraph team maintains several officially supported client libraries. There are also libraries contributed by the community unofficial client libraries.

Contact