My HyGraph Package
Description
This package provides tools for managing and analyzing HyGraph data.
Installation
To install the package, use the following command: pip install hygraph-core
Usage
from hygraph_core import HyGraph, HyGraphQuery
# Initialize HyGraph
hygraph = HyGraph()
# Sample data for nodes and edges
# Creating nodes
node1 = hygraph.add_pgnode(oid=1, label="Node1", start_time=pd.to_datetime("2023-01-01"))
node2 = hygraph.add_pgnode(oid=2, label="Node2", start_time=pd.to_datetime("2023-01-01"))
# Adding static properties to nodes
node1.add_static_property("description", "This is node 1", hygraph)
node2.add_static_property("description", "This is node 2", hygraph)
# Create an edge with static and dynamic properties
edge = hygraph.add_pgedge(
oid=10,
source=node1.getId(),
target=node2.getId(),
label="Edge1",
start_time=pd.to_datetime("2023-01-01"),
properties={"weight": 5}
)
# Define timestamps and values
timestamps = pd.to_datetime(["2023-01-01", "2023-01-02", "2023-01-03"])
values = [[1], [3], [5]]
# Create the time series
metadata = TimeSeriesMetadata(owner_id=edge.getId(), element_type='edge') # or whatever the correct metadata is
time_series = TimeSeries(tsid='traffic_series', timestamps=timestamps, variables=['traffic'], data=values,
metadata=metadata)
# Add a dynamic property to the edge (if supported in your implementation)
edge.add_temporal_property("traffic", time_series, hygraph)
# Query example: retrieve all edges between `Node1` and `Node2`
query = HyGraphQuery(hygraph) \
.match_node(alias='node1', node_id=node1.getId()) \
.match_edge(alias='edge') \
.match_node(alias='node2', node_id=node2.getId()) \
.connect('node1', 'edge', 'node2') \
.return_(edge=lambda result: result['edge'])
# Execute query and print results
edges = query.execute()
print("Edges between Node1 and Node2:", edges)
# Display nodes, edges, and properties
print("Nodes and their properties:")
for node_id, data in hygraph.graph.nodes(data=True):
print(f"Node ID: {node_id}, Data: {data}")
print("\nEdges and their properties:")
for u, v, data in hygraph.graph.edges(data=True):
print(f"Edge from {u} to {v}, Data: {data}")
# Example usage here
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hygraph_core-0.3.9.9.tar.gz
(71.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hygraph_core-0.3.9.9.tar.gz.
File metadata
- Download URL: hygraph_core-0.3.9.9.tar.gz
- Upload date:
- Size: 71.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed939e092e761de1e40cdffc9816d4fa8dd9ef47b25840444c16c8ef5a461785
|
|
| MD5 |
4506395c7435c84bccc5e90d6d9ff35a
|
|
| BLAKE2b-256 |
cfc8e68cb4e29254208cd641c520bac954b02c617d9b2c40925abea7a9f7db88
|
File details
Details for the file hygraph_core-0.3.9.9-py3-none-any.whl.
File metadata
- Download URL: hygraph_core-0.3.9.9-py3-none-any.whl
- Upload date:
- Size: 80.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c82909de7b044ba165d0330536401e63bed49b2a9f92ba72461095006fc1eea9
|
|
| MD5 |
6259103581fa222201cc59437bd36c10
|
|
| BLAKE2b-256 |
333032522c9d13217612d3f1342c0e9c794067dc9a7c487bdbc5bd8cb4803585
|