Metadata-Version: 2.1
Name: HARPGraph2
Version: 0.1.0
Summary: A generalized graph library for dealing with generalized graph structures.
Home-page: https://github.com/HARP-research-Inc/HARPGraph2
Author: Harper Chisari
Author-email: harper.chisari@harpresearch.ai
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: networkx
Requires-Dist: matplotlib

## <img src="https://static.wixstatic.com/media/355b75_1c4e29d87f1e449cbdfdb2b623ac66ce~mv2.png/v1/fill/w_292,h_72,fp_0.50_0.50,q_85,usm_0.66_1.00_0.01,enc_auto/355b75_1c4e29d87f1e449cbdfdb2b623ac66ce~mv2.png" width="100"> research, Inc. - **HARPGraph2**

# HARPGraph2  (v0.1.0)
A generalized graph library for dealing with generalized graph structures. - Made by Harper Chisari

## PseudoDiGraph

`PseudoDiGraph` is a class that supports both directed and undirected edges, as well as hyperedges. It uses an incidence matrix to represent the graph, where:

- `1` represents an undirected edge.
- `0.5` represents a directed edge away from a node.
- `-0.5` represents a directed edge towards a node.

### Features

1. **Adding Nodes and Edges**
   - `add_node(node)`: Adds a node to the graph.
   - `add_edge(nodes)`: Adds an edge to the graph. If `nodes` is a tuple, it is treated as a directed edge; if it is a list, it is treated as an undirected edge.

2. **Removing Nodes and Edges**
   - `remove_node(node)`: Removes a node and all edges connected to it from the graph.
   - `remove_edge(nodes)`: Removes a specified edge from the graph.

3. **Getting Edges**
   - `get_undirected_edges(nodes=None)`: Returns all undirected edges. If `nodes` is specified, only edges involving those nodes are returned.
   - `get_directed_edges(nodes=None)`: Returns all directed edges. If `nodes` is specified, only edges involving those nodes are returned.

4. **Plotting and Exporting**
   - `plot()`: Plots the graph and stores the coordinates for future exports.
   - `export(output_folder='output_images', filename='graph_plot.png')`: Exports the graph plot to a specified file using the coordinates generated by `plot()`.

### Examples

#### Creating a Directed Graph

```python
from HARPGraph2 import PseudoDiGraph

# Create a directed graph
graph = PseudoDiGraph(directed=True)
graph.add_edge(('A', 'B'))  # Directed edge from A to B
print("Directed edges:", graph.get_directed_edges())
graph.plot()  # Displays the plot
graph.export()  # Saves the plot to the default 'output_images/graph_plot.png'
```

#### Creating an Undirected Graph

```python
from HARPGraph2 import PseudoDiGraph

# Create an undirected graph
graph = PseudoDiGraph()
graph.add_node('C')
graph.add_node('D')
graph.add_edge(('C', 'D'))  # Unordered hyper edge between C and D
graph.add_node('E')
graph.add_node('F')
graph.add_edge(('D', 'E'))  # Directed edge from D to E
graph.add_edge(('E', 'C'))  # Directed edge from E to D
graph.add_edge(['C', 'F'])  # Undirected edge between C and F
print("Undirected edges:", graph.get_undirected_edges())
print("Directed edges:", graph.get_directed_edges())
graph.plot()  # Displays the plot
graph.export(output_folder="output_images")  # Saves the plot to the default 'output_images/graph_plot.png'
```

#### Removing Nodes and Edges
```python
from HARPGraph2 import PseudoDiGraph

# Create a graph and add nodes and edges
graph = PseudoDiGraph()
graph.add_node('C')
graph.add_node('D')
graph.add_edge(('C', 'D'))  # Unordered hyper edge between C and D
graph.add_node('E')
graph.add_node('F')
graph.add_edge(('D', 'E'))  # Directed edge from D to E
graph.add_edge(('E', 'C'))  # Directed edge from E to D
graph.add_edge(['C', 'F'])  # Undirected edge between C and F

# Remove edges and nodes
graph.remove_edge(('C', 'D'))
graph.remove_node('E')
print("Undirected edges after removal:", graph.get_undirected_edges())
print("Directed edges after removal:", graph.get_directed_edges())
graph.plot()  # Displays the plot after removals
graph.export(output_folder="output_images", filename="graph_plot_after_removal.png")  # Saves the plot to 'output_images/graph_plot_after_removal.png'
```

## Installation
To install the library, clone the repository and run:
```python
pip install HARPGraph2
```



${\color{grey}\textsf{Copyright © 2024 HARP research, Inc. Visit us at }}$ [https://harpresearch.ai](https://harpresearch.ai)

