Skip to content

Commit

Permalink
bump version to 0.3.1 + minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
erivlis committed Jul 2, 2024
1 parent 926b625 commit 785ef67
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
19 changes: 11 additions & 8 deletions examples/math/polygonal_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@
import graphinate.modeling
import networkx as nx

N: int = 8

def polygonal_graph_edges(edges_count: int):
for i in range(1, edges_count):
yield {'source': i, 'target': i + 1}
yield {'source': edges_count, 'target': 1}

def polygonal_graph_model(number_of_sides: int = N):

def polygonal_graph_model(name: str, number_of_sides: int) -> graphinate.GraphModel:
"""
Create a polygonal graph model.
Args:
number_of_sides (int): Number of sides in the polygon. Defaults to N.
name (str): The Graph's name.
number_of_sides (int): Number of sides in the polygon.
Returns:
GraphModel: A graph model representing a polygonal graph.
"""

# Define GraphModel
graph_model = graphinate.model(name="Octagonal Graph")
graph_model = graphinate.model(name)

# Register edges supplier function
@graph_model.edge()
def edge():
for i in range(number_of_sides - 1):
yield {'source': i, 'target': i + 1}
yield {'source': number_of_sides - 1, 'target': 0}
yield from polygonal_graph_edges(number_of_sides)

return graph_model


model = polygonal_graph_model()
model = polygonal_graph_model("Octagonal Graph", 8)

if __name__ == '__main__':
use_materialize = True
Expand Down
3 changes: 2 additions & 1 deletion examples/web/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
beautifulsoup4~=4.12.2
loguru
lxml~=4.9.3
requests~=2.31.0
requests~=2.32.0
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "Graphinate"
version = "0.3.0"
version = "0.3.1"
authors = [
{ name = "Eran Rivlis", email = "[email protected]" },
]
Expand Down
8 changes: 4 additions & 4 deletions src/graphinate/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def from_networkx(nx_graph: nx.Graph):
class GraphQLBuilder(NetworkxBuilder):
"""Builds a GraphQL Schema"""

# region Strawberry Types
# region - Strawberry Types

InfNumber = strawberry.scalar(
converters.InfNumber,
Expand Down Expand Up @@ -504,7 +504,7 @@ class GraphMeasure(Enum):
overall_reciprocity = 'overall_reciprocity'
wiener_index = 'wiener_index'

# endregion Strawberry Types
# endregion - Strawberry Types

def __init__(self, model: GraphModel, graph_type: GraphType = GraphType.Graph):
super().__init__(model, graph_type)
Expand Down Expand Up @@ -705,15 +705,15 @@ def filter_edge(edge):
self.add_field_resolver(query_class_dict, 'edges', graph_edges_resolver())
# endregion

# region - Defining GraphQL Query Class dict - fields for GraphQL types implementing 'GraphNode' interface
# region - Defining GraphQL Query Class dict - fields for GraphQL types implementing 'GraphNode' interface
for node_type, graphql_type in self._graphql_types.items():
field_name = inflection.plural(node_type)
resolver = graph_nodes_resolver(graphql_type, node_type)
self.add_field_resolver(query_class_dict, field_name, resolver)

# endregion

# region - Defining GraphQL Query Class dict - field measure for 'GraphMeasure' GraphQL type
# region - Defining GraphQL Query Class dict - field measure for 'GraphMeasure' GraphQL type

def graph_measure(self, measure: GraphQLBuilder.GraphMeasure) -> GraphQLBuilder.Measure:

Expand Down

0 comments on commit 785ef67

Please sign in to comment.