Property graph benchmark with node and edges generation, multiple output formats, and visualization
2.3K

Knows is a powerful and user-friendly tool for generating property graphs. These graphs are crucial in many fields. Knows supports multiple output formats, schema files and basic visualization capabilities, making it a go-to tool for researchers, educators and data enthusiasts.
Install with uvβ , pipxβ or pip:
uv tool install "knows[all]"
# or: pipx install "knows[all]"
# or: pip install "knows[all]"
# Generate a random graph (default: YARS-PG format)
knows
# 10 nodes, 5 edges β GraphML file
knows -n 10 -e 5 -f graphml graph.graphml
# Visualize as PNG
knows -n 20 -e 15 -f png graph.png
# Export to CSV (creates graph_nodes.csv + graph_edges.csv)
knows -n 10 -e 8 -f csv graph.csv
# Use a custom schema
knows -n 10 -e 15 --schema schema-examples/employee_schema.json -f cypher
Or with Docker - no installation needed:
docker run --rm lszeremeta/knows -n 10 -e 5 -f graphml
Run knows -h to see all options. For more install methods see the Installation section, for all options and more
examples see the Usage section below. Custom node/edge types are covered in
SCHEMA.mdβ , writing your own output formats in
PLUGINS.mdβ .
-s/--seed option regardless of the selected
output format.Note on reproducibility: The
-s/--seedoption makes the random aspects of graph generation deterministic within the same software environment. Results may still differ across versions of Python or dependencies.
Built-in graph structure:
Person with unique IDs (N1, N2, N3, ..., Nn).firstName and lastName properties by default.knows and include strength [1..100] and lastMeetingDate [1955-01-01..2025-06-28] properties by
default.favoriteColorcompanyjobphoneNumberpostalAddressfriendCount (actual node degree - number of unique connections)preferredContactMethod [inPerson, email, postalMail, phone, textMessage, videoCall, noPreference]lastMeetingCitymeetingCount [1..10000]lastMeetingCity, lastMeetingDate, and
meetingCount values.You can define custom graph structures using schema files. See SCHEMA.mdβ for details and examples.
Knows uses a modular plugin architecture for output formats. Every format - including all 14 built-in ones - is a plugin
discovered at runtime via Python's standard entry_points mechanism. This means you can:
A format plugin is any Python object that provides a name, description, output_kind, default_extension, and a
convert(graph, ctx) method. No base class inheritance is required - Knows uses structural typing (duck typing with
protocol checks). The ctx parameter is a ConvertContext carrying visualization settings (viz_limit, show_info)
that visual formats use and text formats can ignore. Plugins can also produce visual output - either by using the
built-in GraphDrawer helper or a custom rendering pipeline.
For a step-by-step guide on creating and registering plugins (including visual formats), see PLUGINS.mdβ .
You can install knows via PyPI, Docker or run it from the source code.
Installation with uvβ , pipxβ or pip:
uv tool install "knows[all]"
pipx install "knows[all]"
pip install "knows[all]"
Knows is a command-line tool, so uv tool install and pipx install are the recommended options - they install
Knows into an isolated environment and make the knows command available globally.
The all extra installs all optional dependencies - currently the matplotlib and scipy libraries needed for
graph visualization (svg, png, jpg and pdf formats and the -d option). You can omit [all] if you
don't need visualization. knows[all] is an alias for knows[draw] - both work.
Running Knows:
knows [options]
Pull Image:
docker pull lszeremeta/knows
Run Container:
docker run --rm lszeremeta/knows [options]
Build Image:
docker build -t knows .
Run Container:
docker run --rm knows [options]
See Docker examples in Practical Examples section.
Clone Repository:
git clone [email protected]:lszeremeta/knows.git
cd knows
Install Requirements:
pip install ".[all]"
Execute Knows:
python -m knows [options]
The -d/--draw option requires Tkinter. You can check whether visualization is available in your environment
with knows --version.
Ubuntu:
sudo apt update
sudo apt install python3-tk
See Installing Tkinter on Ubuntuβ for details.
macOS (Homebrew):
brew install python3
brew install python-tk
See Installing Tkinter on macOSβ for details.
Windows: On Windows, Tkinter should be installed by default with Python. No additional steps required.
usage: knows [-h] [-n NODES] [-e EDGES] [-s SEED] [-v]
[-f {graphml,yarspg,csv,cypher,gexf,gml,svg,png,jpg,pdf,adjacency_list,multiline_adjacency_list,edge_list,json}]
[--schema FILE] [-l LOCALE]
[-np [{firstName,lastName,company,job,phoneNumber,favoriteColor,postalAddress,preferredContactMethod,friendCount} ...]]
[-ep [{strength,lastMeetingCity,lastMeetingDate,meetingCount} ...]] [-ap] [-d] [--debug] [--limit N] [--no-limit]
[--hide-info] [output]
Available options may vary depending on the version. To display all available options with their descriptions use
knows -h.
output: Optional path to save the graph. For CSV format two files will be created: *_nodes.csv and *_edges.csv.-h, --help: Show help message and exit.-n NODES, --nodes NODES: Number of nodes in the graph. Selected randomly if not specified.-e EDGES, --edges EDGES: Number of edges in the graph. Selected randomly if not specified.-s SEED, --seed SEED: Seed for random number generation to ensure reproducible results (also between various
output formats).-v, --version: Show program version, environment and plugin diagnostics, and exit. The report includes dependency
versions, visualization availability, install source (PyPI, Docker, local) and installed format plugins - paste it
into bug reports.-f {graphml,yarspg,csv,cypher,gexf,gml,svg,png,jpg,pdf,adjacency_list,multiline_adjacency_list,edge_list,json}, --format {graphml,yarspg,csv,cypher,gexf,gml,svg,png,jpg,pdf,adjacency_list,multiline_adjacency_list,edge_list,json}:
Format to output the graph. Default: yarspg. The svg, png, jpg and pdf formats are for simple graph
visualization.--schema FILE: Path to JSON schema file defining custom node/edge types and properties. When specified,
overrides -np, -ep, and -ap options. GQL-inspired schema format (ISO/IEC 39075β ).
See SCHEMA.mdβ for details.-l LOCALE, --locale LOCALE: Locale code for generated property values (e.g. pl_PL, de_DE, ja_JP). Default: en_US.
See the list of supported localesβ .-np [{firstName,lastName,company,job,phoneNumber,favoriteColor,postalAddress,preferredContactMethod,friendCount} ...], --node-props [{firstName,lastName,company,job,phoneNumber,favoriteColor,postalAddress,preferredContactMethod,friendCount} ...]:
Space-separated node properties. Available: firstName, lastName, company, job, phoneNumber, favoriteColor,
postalAddress, preferredContactMethod, friendCount. Ignored when --schema is used.-ep [{strength,lastMeetingCity,lastMeetingDate,meetingCount} ...],--edge-props [{strength,lastMeetingCity,lastMeetingDate,meetingCount} ...]:strength, lastMeetingCity, lastMeetingDate, meetingCount. Ignored when --schema is used.-ap, --all-props: Use all available node and edge properties. Ignored when --schema is used.-d, --draw: Show interactive graph window. Requires Tkinter. May not work in Docker.--debug: Show full tracebacks instead of short error messages.--limit N: Maximum nodes to display (default: 50). Shows subgraph centered on most connected nodes.--no-limit: Show full graph without node limit.--hide-info: Hide node count info (e.g., 50/200 nodes) from output.knows
# or
docker run --rm lszeremeta/knows
knows -n 100 -e 70 -f graphml > graph.graphml
# or
knows -n 100 -e 70 -f graphml graph.graphml
# or
docker run --rm lszeremeta/knows -n 100 -e 70 -f graphml > graph.graphml
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 100 -e 70 -f graphml /data/graph.graphml
knows -f csv > nodes.csv 2> edges.csv
# or
knows -f csv graph.csv
# or
docker run --rm lszeremeta/knows -f csv > nodes.csv 2> edges.csv
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -f csv /data/graph.csv
graph_nodes.csv and graph_edges.csv.knows -n 50 -e 20 -f cypher > graph.cypher
# or
knows -n 50 -e 20 -f cypher graph.cypher
# or
docker run --rm lszeremeta/knows -n 50 -e 20 -f cypher > graph.cypher
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 50 -e 20 -f cypher /data/graph.cypher
knows -n 100 -e 50 > graph.yarspg
# or
knows -n 100 -e 50 graph.yarspg
# or
docker run --rm lszeremeta/knows -n 100 -e 50 > graph.yarspg
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 100 -e 50 /data/graph.yarspg
knows -n 100 -e 50 -f svg -d > graph.svg
# or
knows -n 100 -e 50 -f svg -d graph.svg
knows -n 70 -e 50 -f svg > graph.svg
# or
knows -n 70 -e 50 -f svg graph.svg
# or
docker run --rm lszeremeta/knows -n 70 -e 50 -f svg > graph.svg
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 70 -e 50 -f svg /data/graph.svg
knows -n 10 -e 5 -f png > graph.png
# or
knows -n 10 -e 5 -f png graph.png
# or
docker run --rm lszeremeta/knows -n 10 -e 5 -f png > graph.png
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 10 -e 5 -f png /data/graph.png
knows -f json > graph.json
# or
knows -f json graph.json
# or
docker run --rm lszeremeta/knows -f json > graph.json
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -f json /data/graph.json
knows -n 20 -e 10 -np firstName favoriteColor job -ep lastMeetingCity
# or
docker run --rm lszeremeta/knows -n 20 -e 10 -np firstName favoriteColor job -ep lastMeetingCity
knows -ap > graph.yarspg
# or
knows -ap graph.yarspg
# or
docker run --rm lszeremeta/knows -ap > graph.yarspg
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -ap /data/graph.yarspg
knows -n 3 -e 2 -s 43 -f csv
# or
docker run --rm lszeremeta/knows -n 3 -e 2 -s 43 -f csv
Running the command again with the same seed will produce the identical graph, provided the environment and dependencies remain unchanged.
knows -n 3 -e 2 -s 43
# or
docker run --rm lszeremeta/knows -n 3 -e 2 -s 43
knows -n 10 -e 15 --schema schema-examples/employee_schema.json
# or
knows -n 10 -e 15 --schema schema-examples/employee_schema.json -f cypher > employees.cypher
# or with Docker (using built-in example schemas)
docker run --rm lszeremeta/knows --schema /app/schema-examples/employee_schema.json -n 10 -e 15
docker run --rm -v "$(pwd)":/data lszeremeta/knows --schema /app/schema-examples/employee_schema.json -n 10 -e 15 -f cypher /data/employees.cypher
See SCHEMA.mdβ for full schema documentation and more examples.
knows -n 500 -e 300 -f svg --limit 100 > graph.svg
# or
docker run --rm lszeremeta/knows -n 500 -e 300 -f svg --limit 100 > graph.svg
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 500 -e 300 -f svg --limit 100 /data/graph.svg
This limits the visualization to 100 nodes (default is 50), centered on the most connected nodes.
knows -n 200 -e 150 -f png --no-limit > graph.png
# or
docker run --rm lszeremeta/knows -n 200 -e 150 -f png --no-limit > graph.png
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 200 -e 150 -f png --no-limit /data/graph.png
knows -n 300 -e 200 -f svg --hide-info > graph.svg
# or
docker run --rm lszeremeta/knows -n 300 -e 200 -f svg --hide-info > graph.svg
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 300 -e 200 -f svg --hide-info /data/graph.svg
knows -n 10 -e 0 -f graphml > nodes_only.graphml
# or
docker run --rm lszeremeta/knows -n 10 -e 0 -f graphml > nodes_only.graphml
# or
docker run --rm -v "$(pwd)":/data lszeremeta/knows -n 10 -e 0 -f graphml /data/nodes_only.graphml
knows -n 10 -e 5 -l pl_PL -f cypher
# or
docker run --rm lszeremeta/knows -n 10 -e 5 -l pl_PL -f cypher
Note: On Windows PowerShell, replace
$(pwd)with${PWD}. On Windows Command Prompt, use%cd%.
Your ideas and contributions can make Knows even better! If you're new to open source, read How to Contribute to Open Sourceβ and CONTRIBUTING.mdβ .
Knows is licensed under the MIT Licenseβ .
Content type
Image
Digest
sha256:6144ece9dβ¦
Size
149.1 MB
Last updated
3 months ago
docker pull lszeremeta/knows