diff --git a/MANIFEST.in b/MANIFEST.in index c9af280..a3a0c19 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,8 @@ include planarity/c/LICENSE.TXT include README.md include planarity/c/README +recursive-include planarity/c/ *.h + include planarity/classic/cplanarity.pxd include planarity/classic/planarity.c include planarity/classic/planarity.pyx diff --git a/planarity/__init__.py b/planarity/__init__.py index a5645d8..2baf2a4 100644 --- a/planarity/__init__.py +++ b/planarity/__init__.py @@ -8,6 +8,7 @@ gp_GetLibPlanarityVersionFull, Graph, OK, + AT_EDGE_CAPACITY_LIMIT, NONEMBEDDABLE, NOTOK, NIL, @@ -21,4 +22,4 @@ # NOTE: In the future, we could automatically generate the version number by # configuring setuptools-scm, but presently this seems simpler. -__version__ = "0.7.11" +__version__ = "0.7.13" diff --git a/planarity/c/graphLib/extensionSystem/graphExtensions.c b/planarity/c/graphLib/extensionSystem/graphExtensions.c index c4778a9..100f83e 100644 --- a/planarity/c/graphLib/extensionSystem/graphExtensions.c +++ b/planarity/c/graphLib/extensionSystem/graphExtensions.c @@ -49,7 +49,7 @@ static int moduleIDGenerator = 0; 2) Define an extension context structure to contain all of the data and function pointers that extend the graph. The context must - include a graphFunctionTable to allow overloading of functions. + include a graphFunctionTableStruct to allow overloading of functions. An instance of this context structure is passed to the "context" parameter of gp_AddExtension(). @@ -110,23 +110,22 @@ static int moduleIDGenerator = 0; b) If any data must be associated with vertices and virtual vertices, then it is necessary to perform initialization parallel to the - initialization of anyTypeVertexRec instances. Similarly, if data + initialization of VertexRec instances. Similarly, if data must be associated only with vertices (and not virtual vertices), then initialization parallel to VertexInfo initialization is required. At this time, there do not exist overloadable functions - for fpInitAnyTypeVertexRec() and fpInitVertexInfo(). - Instead, overload fpInitGraph() and fpReinitializeGraph(). Also - if an extension must delete an edge, it should have its own + for fpInitVertexRec() and fpInitVertexInfo(). + Instead, overload fpInitGraph() and fpReinitGraph(). c) If any data must be associated with the edges, then the extension creates a parallel array that is initialized and reinitialized - in overloads of fpInitGraph() and fpReinitializeGraph(). + in overloads of fpInitGraph() and fpReinitGraph(). Also, if the extension deletes edges, then the extension provides its own _Feature_DeleteEdge() that initializes its edge extension data along with calling gp_DeleteEdge(). d) If any graph-level data structures are needed, then an - overload of fpReinitializeGraph() will also be needed, not just the + overload of fpReinitGraph() will also be needed, not just the overload of fpInitGraph(). e) If any data must be persisted in the file format, then overloads @@ -149,7 +148,7 @@ static int moduleIDGenerator = 0; list collection, should be created _and_ initialized. c) The _Feature_InitStructures() should invoke just the functions - needed to initialize the custom AnyTypeVertexRec, VertexInfo and + needed to initialize the custom VertexRec, VertexInfo and EdgeRec data members, if any. 8) Define a function gp_Detach_Feature() that invokes gp_RemoveExtension() @@ -217,7 +216,7 @@ int gp_AddExtension(graphP theGraph, } // Allocate the new extension - if ((newExtension = (graphExtensionP)malloc(sizeof(graphExtension))) == NULL) + if ((newExtension = (graphExtensionP)malloc(sizeof(graphExtensionStruct))) == NULL) { return NOTOK; } @@ -232,7 +231,7 @@ int gp_AddExtension(graphP theGraph, _OverloadFunctions(theGraph, functions); // Make the new linkages - newExtension->next = (struct graphExtension *)theGraph->extensions; + newExtension->next = (struct graphExtensionStruct *)theGraph->extensions; theGraph->extensions = newExtension; // The new extension was successfully added @@ -257,9 +256,9 @@ int gp_AddExtension(graphP theGraph, void _OverloadFunctions(graphP theGraph, graphFunctionTableP functions) { - void **currFunctionTable = (void **)&theGraph->functions; + void **currFunctionTable = (void **)theGraph->functions; void **newFunctionTable = (void **)functions; - int numFunctions = sizeof(theGraph->functions) / sizeof(void *); + int numFunctions = sizeof(graphFunctionTableStruct) / sizeof(void *); int K; for (K = 0; K < numFunctions; K++) @@ -383,7 +382,7 @@ int gp_RemoveExtension(graphP theGraph, int moduleID) // Unhook the curr extension if (prev != NULL) - prev->next = (struct graphExtension *)next; + prev->next = (struct graphExtensionStruct *)next; else theGraph->extensions = next; @@ -473,7 +472,7 @@ int gp_CopyExtensions(graphP dstGraph, graphP srcGraph) while (next != NULL) { - if ((newNext = (graphExtensionP)malloc(sizeof(graphExtension))) == NULL) + if ((newNext = (graphExtensionP)malloc(sizeof(graphExtensionStruct))) == NULL) { gp_FreeExtensions(dstGraph); return NOTOK; @@ -487,7 +486,7 @@ int gp_CopyExtensions(graphP dstGraph, graphP srcGraph) newNext->next = NULL; if (newLast != NULL) - newLast->next = (struct graphExtension *)newNext; + newLast->next = (struct graphExtensionStruct *)newNext; else dstGraph->extensions = newNext; diff --git a/planarity/c/graphLib/extensionSystem/graphExtensions.h b/planarity/c/graphLib/extensionSystem/graphExtensions.h index e6d1121..9d09d89 100644 --- a/planarity/c/graphLib/extensionSystem/graphExtensions.h +++ b/planarity/c/graphLib/extensionSystem/graphExtensions.h @@ -12,7 +12,7 @@ extern "C" { #endif -#include "../graphStructures.h" +#include "../graph.h" int gp_AddExtension(graphP theGraph, int *pModuleID, diff --git a/planarity/c/graphLib/extensionSystem/graphExtensions.private.h b/planarity/c/graphLib/extensionSystem/graphExtensions.private.h index b5afd2e..842dc7a 100644 --- a/planarity/c/graphLib/extensionSystem/graphExtensions.private.h +++ b/planarity/c/graphLib/extensionSystem/graphExtensions.private.h @@ -14,7 +14,7 @@ extern "C" { #endif - typedef struct + struct graphExtensionStruct { int moduleID; void *context; @@ -23,10 +23,11 @@ extern "C" graphFunctionTableP functions; - struct graphExtension *next; - } graphExtension; + struct graphExtensionStruct *next; + }; - typedef graphExtension *graphExtensionP; + typedef struct graphExtensionStruct graphExtensionStruct; + typedef graphExtensionStruct *graphExtensionP; #ifdef __cplusplus } diff --git a/planarity/c/graphLib/extensionSystem/graphFunctionTable.h b/planarity/c/graphLib/extensionSystem/graphFunctionTable.h index cc3a7d5..3fdd306 100644 --- a/planarity/c/graphLib/extensionSystem/graphFunctionTable.h +++ b/planarity/c/graphLib/extensionSystem/graphFunctionTable.h @@ -14,12 +14,12 @@ extern "C" /* NOTE: If you add any FUNCTION POINTERS to this function table, then you must - also initialize them in _InitFunctionTable() in graphUtils.c. + also initialize them in _InitFunctionTable() in graph.c. */ - typedef struct baseGraphStructure baseGraphStructure; - typedef baseGraphStructure *graphP; + typedef struct graphStruct graphStruct; + typedef graphStruct *graphP; - typedef struct + struct graphFunctionTableStruct { // These function pointers allow extension modules to overload some of // the behaviors of protected functions. Only advanced applications @@ -41,7 +41,7 @@ extern "C" // These function pointers allow extension modules to overload some // of the behaviors of gp_* function in the public API int (*fpInitGraph)(graphP, int); - void (*fpReinitializeGraph)(graphP); + void (*fpReinitGraph)(graphP); int (*fpEnsureEdgeCapacity)(graphP, int); int (*fpSortVertices)(graphP); @@ -54,10 +54,10 @@ extern "C" int (*fpRestoreVertex)(graphP); int (*fpContractEdge)(graphP, int); int (*fpIdentifyVertices)(graphP, int, int, int); + }; - } graphFunctionTable; - - typedef graphFunctionTable *graphFunctionTableP; + typedef struct graphFunctionTableStruct graphFunctionTableStruct; + typedef graphFunctionTableStruct *graphFunctionTableP; #ifdef __cplusplus } diff --git a/planarity/c/graphLib/graphUtils.c b/planarity/c/graphLib/graph.c similarity index 79% rename from planarity/c/graphLib/graphUtils.c rename to planarity/c/graphLib/graph.c index 5ceb730..614a7b5 100644 --- a/planarity/c/graphLib/graphUtils.c +++ b/planarity/c/graphLib/graph.c @@ -4,9 +4,16 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include +#include "graph.h" +#include "graph.private.h" + +// To enable performing of certain initialization calls for the +// DFSUtils, Planarity, and Outerplanarity pseudo-extensions. +#include "planarityRelated/graphPlanarity.h" +#include "planarityRelated/graphPlanarity.private.h" +#include "planarityRelated/graphOuterplanarity.h" -#include "graphLib.h" +#include /* Imported functions for FUNCTION POINTERS */ @@ -41,7 +48,7 @@ int _RestoreVertex(graphP theGraph); void _InitIsolatorContext(graphP theGraph); void _ClearAllVisitedFlagsInGraph(graphP theGraph); -void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int includeVirtualVertices); +void _ClearVertexVisitedFlags(graphP theGraph, int includeVirtualVertices); void _ClearEdgeVisitedFlags(graphP theGraph); int _ClearAllVisitedFlagsInBicomp(graphP theGraph, int BicompRoot); int _ClearAllVisitedFlagsInOtherBicomps(graphP theGraph, int BicompRoot); @@ -67,11 +74,6 @@ int _ClearInvertedFlagsInBicomp(graphP theGraph, int BicompRoot); void _InitFunctionTable(graphP theGraph); -// Eliminates missingprototype warning -#ifndef DEBUG -int debugNOTOK(void); -#endif - /******************************************************************** Private functions. ********************************************************************/ @@ -92,45 +94,14 @@ void _RestoreEdgeRecord(graphP theGraph, int e); /* Private functions for which there are FUNCTION POINTERS */ -void _InitAnyTypeVertexRec(graphP theGraph, int v); +void _InitVertexRec(graphP theGraph, int v); void _InitVertexInfo(graphP theGraph, int v); void _InitEdgeRec(graphP theGraph, int e); int _InitGraph(graphP theGraph, int N); -void _ReinitializeGraph(graphP theGraph); +void _ReinitGraph(graphP theGraph); int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity); -/******************************************************************** - gp_GetProjectVersionFull() - Return full major.minor.maint.tweak version string for the graph planarity project - ********************************************************************/ - -char *gp_GetProjectVersionFull(void) -{ - static char projectVersionStr[MAXLINE + 1]; - sprintf(projectVersionStr, "%d.%d.%d.%d", - GP_PROJECTVERSION_MAJOR, - GP_PROJECTVERSION_MINOR, - GP_PROJECTVERSION_MAINT, - GP_PROJECTVERSION_TWEAK); - return projectVersionStr; -} - -/******************************************************************** - gp_GetLibPlanarityVersionFull() - Returns full current:revision:age version string for the graph planarity shared library - ********************************************************************/ - -char *gp_GetLibPlanarityVersionFull(void) -{ - static char libPlanarityVersionStr[MAXLINE + 1]; - sprintf(libPlanarityVersionStr, "%d:%d:%d", - GP_LIBPLANARITYVERSION_CURRENT, - GP_LIBPLANARITYVERSION_REVISION, - GP_LIBPLANARITYVERSION_AGE); - return libPlanarityVersionStr; -} - /******************************************************************** gp_New() Constructor for graph object. @@ -139,28 +110,29 @@ char *gp_GetLibPlanarityVersionFull(void) graphP gp_New(void) { - graphP theGraph = (graphP)malloc(sizeof(baseGraphStructure)); + graphP theGraph = (graphP)calloc(1, sizeof(graphStruct)); + graphFunctionTableP functionTable = (graphFunctionTableP)calloc(1, sizeof(graphFunctionTableStruct)); - if (theGraph != NULL) + if (theGraph != NULL && functionTable != NULL) { - theGraph->E = NULL; - theGraph->V = NULL; - theGraph->VI = NULL; - - theGraph->BicompRootLists = NULL; - theGraph->sortedDFSChildLists = NULL; - theGraph->theStack = NULL; - - theGraph->extFace = NULL; - - theGraph->edgeHoles = NULL; - - theGraph->extensions = NULL; - + // All pointers within the graph are NULL due to using calloc() above + theGraph->functions = functionTable; _InitFunctionTable(theGraph); - _ClearGraph(theGraph); } + else + { + if (theGraph != NULL) + { + free(theGraph); + theGraph = NULL; + } + if (functionTable != NULL) + { + free(functionTable); + functionTable = NULL; + } + } return theGraph; } @@ -170,7 +142,7 @@ graphP gp_New(void) If you add functions to the function table, then they must be initialized here, but you must also add the new function pointer - to the definition of the graphFunctionTable in graphFunctionTable.h + to the definition of the graphFunctionTableStruct in graphFunctionTable.h Function headers for the functions used to initialize the table are classified at the top of this file as either imported from other @@ -181,57 +153,65 @@ graphP gp_New(void) void _InitFunctionTable(graphP theGraph) { - theGraph->functions.fpEmbeddingInitialize = _EmbeddingInitialize; - theGraph->functions.fpEmbedBackEdgeToDescendant = _EmbedBackEdgeToDescendant; - theGraph->functions.fpWalkUp = _WalkUp; - theGraph->functions.fpWalkDown = _WalkDown; - theGraph->functions.fpMergeBicomps = _MergeBicomps; - theGraph->functions.fpMergeVertex = _MergeVertex; - theGraph->functions.fpHandleBlockedBicomp = _HandleBlockedBicomp; - theGraph->functions.fpHandleInactiveVertex = _HandleInactiveVertex; - theGraph->functions.fpEmbedPostprocess = _EmbedPostprocess; - theGraph->functions.fpMarkDFSPath = _MarkDFSPath; - theGraph->functions.fpCheckEmbeddingIntegrity = _CheckEmbeddingIntegrity; - theGraph->functions.fpCheckObstructionIntegrity = _CheckObstructionIntegrity; - - theGraph->functions.fpInitGraph = _InitGraph; - theGraph->functions.fpReinitializeGraph = _ReinitializeGraph; - theGraph->functions.fpEnsureEdgeCapacity = _EnsureEdgeCapacity; - theGraph->functions.fpSortVertices = _SortVertices; - - theGraph->functions.fpReadPostprocess = _ReadPostprocess; - theGraph->functions.fpWritePostprocess = _WritePostprocess; - - theGraph->functions.fpHideEdge = _HideEdge; - theGraph->functions.fpRestoreEdge = _RestoreEdge; - theGraph->functions.fpHideVertex = _HideVertex; - theGraph->functions.fpRestoreVertex = _RestoreVertex; - theGraph->functions.fpContractEdge = _ContractEdge; - theGraph->functions.fpIdentifyVertices = _IdentifyVertices; + if (theGraph != NULL && theGraph->functions != NULL) + { + theGraph->functions->fpEmbeddingInitialize = _EmbeddingInitialize; + theGraph->functions->fpEmbedBackEdgeToDescendant = _EmbedBackEdgeToDescendant; + theGraph->functions->fpWalkUp = _WalkUp; + theGraph->functions->fpWalkDown = _WalkDown; + theGraph->functions->fpMergeBicomps = _MergeBicomps; + theGraph->functions->fpMergeVertex = _MergeVertex; + theGraph->functions->fpHandleBlockedBicomp = _HandleBlockedBicomp; + theGraph->functions->fpHandleInactiveVertex = _HandleInactiveVertex; + theGraph->functions->fpEmbedPostprocess = _EmbedPostprocess; + theGraph->functions->fpMarkDFSPath = _MarkDFSPath; + theGraph->functions->fpCheckEmbeddingIntegrity = _CheckEmbeddingIntegrity; + theGraph->functions->fpCheckObstructionIntegrity = _CheckObstructionIntegrity; + + theGraph->functions->fpInitGraph = _InitGraph; + theGraph->functions->fpReinitGraph = _ReinitGraph; + theGraph->functions->fpEnsureEdgeCapacity = _EnsureEdgeCapacity; + theGraph->functions->fpSortVertices = _SortVertices; + + theGraph->functions->fpReadPostprocess = _ReadPostprocess; + theGraph->functions->fpWritePostprocess = _WritePostprocess; + + theGraph->functions->fpHideEdge = _HideEdge; + theGraph->functions->fpRestoreEdge = _RestoreEdge; + theGraph->functions->fpHideVertex = _HideVertex; + theGraph->functions->fpRestoreVertex = _RestoreVertex; + theGraph->functions->fpContractEdge = _ContractEdge; + theGraph->functions->fpIdentifyVertices = _IdentifyVertices; + } } /******************************************************************** gp_InitGraph() Allocates memory for vertex and edge records now that N is known. - The edgeCapacity is set to (DEFAULT_EDGE_LIMIT * N) unless it + The edgeCapacity is set to (DEFAULT_EDGE_CAPACITY_FACTOR * N) unless it has already been set by gp_EnsureEdgeCapacity() For V, we need 2N vertex records, N for vertices and N for virtual vertices (root copies). - For VI, we need N vertexInfo records. + For E, we need 2*edgeCapacity edge records (plus 2 for default of using 1-based arrays). - For E, we need 2*edgeCapacity edge records (plus 2 for default of using faster 1-based arrays). + The edgeHoles stack, initially empty, is set to the edgeCapacity, + which is big enough to push every edge (to indicate an edge + you only need to indicate one of its two edge records). - The BicompRootLists and sortedDFSChildLists are of size N and start out empty. + The numEdgeHoles member tracks the size of the edgeHoles stack so that + the number of edges in use within E can be efficiently computed. The stack, initially empty, is made big enough for a pair of integers per edge (2 * edgeCapacity), or 6N integers if the edgeCapacity was set below the default value. Space for 2 extra integers is added to allow depth-first search to push (NIL, NIL) to start at a DFS tree root - The edgeHoles stack, initially empty, is set to the edgeCapacity, - which is big enough to push every edge (to indicate an edge - you only need to indicate one of its two edge records) + The BicompRootLists and sortedDFSChildLists are of size N and start out empty. + + For each DVI and PVI, we need N of each of the respective vertex info records. + + For the isolator context, we need a single instance. Returns OK on success, NOTOK on all failures. On NOTOK, graph extensions are freed so that the graph is @@ -248,7 +228,7 @@ int gp_InitGraph(graphP theGraph, int N) if (gp_GetN(theGraph) > 0) return NOTOK; - return theGraph->functions.fpInitGraph(theGraph, N); + return theGraph->functions->fpInitGraph(theGraph, N); } int _InitGraph(graphP theGraph, int N) @@ -258,25 +238,31 @@ int _InitGraph(graphP theGraph, int N) // Compute the vertex and edge capacities of the graph theGraph->N = N; theGraph->NV = N; - theGraph->edgeCapacity = theGraph->edgeCapacity > 0 ? theGraph->edgeCapacity : DEFAULT_EDGE_LIMIT * N; - VIsize = gp_VertexArraySize(theGraph); - Vsize = gp_AnyTypeVertexArraySize(theGraph); - Esize = gp_EdgeArraySize(theGraph); + theGraph->edgeCapacity = theGraph->edgeCapacity > 0 ? theGraph->edgeCapacity : DEFAULT_EDGE_CAPACITY_FACTOR * N; + theGraph->numEdgeHoles = 0; + + VIsize = gp_UpperBoundVertices(theGraph); + Vsize = gp_UpperBoundVertexStorage(theGraph); + Esize = gp_UpperBoundEdgeStorage(theGraph); // Stack size is 2 integers per edge record plus 2 to start depth-first search at a tree root stackSize = (theGraph->edgeCapacity << 2) + 2; // In case of small edgeCapacity, ensure minimum based on number of vertices - stackSize = stackSize <= 2 * 2 * DEFAULT_EDGE_LIMIT * N ? 2 * 2 * DEFAULT_EDGE_LIMIT * N + 2 : stackSize; + stackSize = stackSize <= 2 * 2 * DEFAULT_EDGE_CAPACITY_FACTOR * N ? 2 * 2 * DEFAULT_EDGE_CAPACITY_FACTOR * N + 2 : stackSize; // Allocate memory as described above - if ((theGraph->V = (anyTypeVertexRecP)calloc(Vsize, sizeof(anyTypeVertexRec))) == NULL || - (theGraph->VI = (vertexInfoP)calloc(VIsize, sizeof(vertexInfo))) == NULL || + if ((theGraph->V = (vertexRecP)calloc(Vsize, sizeof(vertexRec))) == NULL || (theGraph->E = (edgeRecP)calloc(Esize, sizeof(edgeRec))) == NULL || + (theGraph->edgeHoles = sp_New(theGraph->edgeCapacity)) == NULL || + + (theGraph->theStack = sp_New(stackSize)) == NULL || (theGraph->BicompRootLists = LCNew(VIsize)) == NULL || + (theGraph->DVI = (DFSUtils_VertexInfoP)calloc(VIsize, sizeof(DFSUtils_VertexInfo))) == NULL || + + (theGraph->PVI = (Planarity_VertexInfoP)calloc(VIsize, sizeof(Planarity_VertexInfo))) == NULL || (theGraph->sortedDFSChildLists = LCNew(VIsize)) == NULL || - (theGraph->theStack = sp_New(stackSize)) == NULL || (theGraph->extFace = (extFaceLinkRecP)calloc(Vsize, sizeof(extFaceLinkRec))) == NULL || - (theGraph->edgeHoles = sp_New(theGraph->edgeCapacity)) == NULL || + (theGraph->IC = (isolatorContextP)calloc(1, sizeof(isolatorContextStruct))) == NULL || 0) { _ClearGraph(theGraph); @@ -296,39 +282,19 @@ int _InitGraph(graphP theGraph, int N) ********************************************************************/ void _InitVertices(graphP theGraph) { -#ifdef USE_FASTER_1BASEDARRAYS - memset(theGraph->V, NIL_CHAR, gp_AnyTypeVertexArraySize(theGraph) * sizeof(anyTypeVertexRec)); - memset(theGraph->VI, NIL_CHAR, gp_VertexArraySize(theGraph) * sizeof(vertexInfo)); - memset(theGraph->extFace, NIL_CHAR, gp_AnyTypeVertexArraySize(theGraph) * sizeof(extFaceLinkRec)); -#else - int v; + memset(theGraph->V, NIL_CHAR, gp_UpperBoundVertexStorage(theGraph) * sizeof(vertexRec)); - memset(theGraph->V, NIL_CHAR, gp_AnyTypeVertexArraySize(theGraph) * sizeof(anyTypeVertexRec)); - memset(theGraph->VI, NIL_CHAR, gp_VertexArraySize(theGraph) * sizeof(vertexInfo)); - memset(theGraph->extFace, NIL_CHAR, gp_AnyTypeVertexArraySize(theGraph) * sizeof(extFaceLinkRec)); + memset(theGraph->DVI, NIL_CHAR, gp_UpperBoundVertices(theGraph) * sizeof(DFSUtils_VertexInfo)); - for (v = gp_GetFirstVertex(theGraph); gp_AnyTypeVertexInRangeAscending(theGraph, v); v++) + memset(theGraph->PVI, NIL_CHAR, gp_UpperBoundVertices(theGraph) * sizeof(Planarity_VertexInfo)); + memset(theGraph->extFace, NIL_CHAR, gp_UpperBoundVertexStorage(theGraph) * sizeof(extFaceLinkRec)); + +#ifdef USE_1BASEDARRAYS +// For 1-based arrays, the memset() initializes the flags correctly +#else + for (int v = gp_LowerBoundVertexStorage(theGraph); v < gp_UpperBoundVertexStorage(theGraph); ++v) gp_InitFlags(theGraph, v); #endif - // N.B. This is the legacy API-based approach to initializing the vertices - // int v; - - // // Initialize the vertices (non-virtual vertices) - // for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) - // { - // _InitAnyTypeVertexRec(theGraph, v); - // _InitVertexInfo(theGraph, v); - // gp_SetExtFaceVertex(theGraph, v, 0, NIL); - // gp_SetExtFaceVertex(theGraph, v, 1, NIL); - // } - - // // Initialize virtual vertices - // for (v = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, v); v++) - // { - // _InitAnyTypeVertexRec(theGraph, v); - // gp_SetExtFaceVertex(theGraph, v, 0, NIL); - // gp_SetExtFaceVertex(theGraph, v, 1, NIL); - // } } /******************************************************************** @@ -336,43 +302,36 @@ void _InitVertices(graphP theGraph) ********************************************************************/ void _InitEdges(graphP theGraph) { -#ifdef USE_FASTER_1BASEDARRAYS - memset(theGraph->E, NIL_CHAR, gp_EdgeArraySize(theGraph) * sizeof(edgeRec)); -#else - int e, Esize; - - memset(theGraph->E, NIL_CHAR, gp_EdgeArraySize(theGraph) * sizeof(edgeRec)); + memset(theGraph->E, NIL_CHAR, gp_UpperBoundEdgeStorage(theGraph) * sizeof(edgeRec)); - Esize = gp_EdgeArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < Esize; e++) +#ifdef USE_1BASEDARRAYS +#else + for (int e = gp_BeginEdgeStorage(theGraph); e != gp_EndEdgeStorage(theGraph); ++e) gp_InitEdgeFlags(theGraph, e); #endif - // N.B. This is the legacy API-based approach to initializing the edges - // int e, Esize; - - // Esize = gp_EdgeArraySize(theGraph); - // for (e = gp_EdgeArrayStart(theGraph); e < Esize; e++) - // _InitEdgeRec(theGraph, e); } /******************************************************************** - gp_ReinitializeGraph() + gp_ReinitGraph() Reinitializes a graph, restoring it to the state it was in immediately after gp_InitGraph() processed it. ********************************************************************/ -void gp_ReinitializeGraph(graphP theGraph) +void gp_ReinitGraph(graphP theGraph) { if (theGraph == NULL || gp_GetN(theGraph) <= 0) return; - theGraph->functions.fpReinitializeGraph(theGraph); + theGraph->functions->fpReinitGraph(theGraph); } -void _ReinitializeGraph(graphP theGraph) +void _ReinitGraph(graphP theGraph) { theGraph->M = 0; - theGraph->graphFlags = theGraph->embedFlags = 0; + theGraph->embedFlags = 0; + + theGraph->graphFlags &= ~GRAPHFLAGS_DFSNUMBERED; + theGraph->graphFlags &= ~GRAPHFLAGS_SORTEDBYDFI; _InitVertices(theGraph); _InitEdges(theGraph); @@ -382,6 +341,7 @@ void _ReinitializeGraph(graphP theGraph) LCReset(theGraph->sortedDFSChildLists); sp_ClearStack(theGraph->theStack); sp_ClearStack(theGraph->edgeHoles); + theGraph->numEdgeHoles = 0; } /******************************************************************** @@ -446,18 +406,17 @@ int gp_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) } // Try to expand the edge capacity - return theGraph->functions.fpEnsureEdgeCapacity(theGraph, requiredEdgeCapacity); + return theGraph->functions->fpEnsureEdgeCapacity(theGraph, requiredEdgeCapacity); } int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) { stackP newStack = NULL; - int e, Esize = gp_EdgeArraySize(theGraph), - newEsize = gp_EdgeArrayStart(theGraph) + (requiredEdgeCapacity << 1); + int newEsize = gp_LowerBoundEdgeStorage(theGraph) + (requiredEdgeCapacity << 1); - // If the new size is less than or equal to the old size, then - // the graph already has the required edge capacity - if (newEsize <= Esize) + // If the new size is less than or equal to the current edge storage size, + // then the graph already has the required edge capacity + if (newEsize <= gp_UpperBoundEdgeStorage(theGraph)) return OK; // Expand theStack. Depth-first search needs 2 integers per edge record @@ -467,7 +426,7 @@ int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) { int newStackSize = 2 * (2 * requiredEdgeCapacity) + 2; - if (newStackSize < 2 * DEFAULT_EDGE_LIMIT * gp_GetN(theGraph) + 2) + if (newStackSize < 2 * DEFAULT_EDGE_CAPACITY_FACTOR * gp_GetN(theGraph) + 2) { // NOTE: We enforce a minimum stack based on number of vertices // if edgeCapacity is small. Currently, this will not @@ -475,7 +434,7 @@ int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) // the capacity can only ever get bigger. However, this // rule is enforced in case future methods are added // that reduce edge capacity - newStackSize = 2 * DEFAULT_EDGE_LIMIT * gp_GetN(theGraph) + 2; + newStackSize = 2 * DEFAULT_EDGE_CAPACITY_FACTOR * gp_GetN(theGraph) + 2; } if ((newStack = sp_New(newStackSize)) == NULL) @@ -495,6 +454,7 @@ int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) sp_CopyContent(newStack, theGraph->edgeHoles); sp_Free(&theGraph->edgeHoles); theGraph->edgeHoles = newStack; + theGraph->numEdgeHoles = sp_GetCurrentSize(theGraph->edgeHoles); // Reallocate the edgeRec array to the new size, theGraph->E = (edgeRecP)realloc(theGraph->E, newEsize * sizeof(edgeRec)); @@ -502,7 +462,7 @@ int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) return NOTOK; // Initialize the new edge records - for (e = Esize; e < newEsize; e++) + for (int e = gp_UpperBoundEdgeStorage(theGraph); e < newEsize; ++e) _InitEdgeRec(theGraph, e); // The new edgeCapacity has been successfully allocated @@ -511,11 +471,11 @@ int _EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) } /******************************************************************** - _InitAnyTypeVertexRec() + _InitVertexRec() Sets the fields in a single vertex record to initial values ********************************************************************/ -void _InitAnyTypeVertexRec(graphP theGraph, int v) +void _InitVertexRec(graphP theGraph, int v) { gp_SetFirstEdge(theGraph, v, NIL); gp_SetLastEdge(theGraph, v, NIL); @@ -561,11 +521,14 @@ void _InitEdgeRec(graphP theGraph, int e) void _InitIsolatorContext(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; - IC->minorType = 0; - IC->v = IC->r = IC->x = IC->y = IC->w = IC->px = IC->py = IC->z = - IC->ux = IC->dx = IC->uy = IC->dy = IC->dw = IC->uz = IC->dz = NIL; + if (IC != NULL) + { + IC->minorType = MINORTYPE_NONE; + IC->v = IC->r = IC->x = IC->y = IC->w = IC->px = IC->py = IC->z = + IC->ux = IC->dx = IC->uy = IC->dy = IC->dw = IC->uz = IC->dz = NIL; + } } /******************************************************************** @@ -574,26 +537,24 @@ void _InitIsolatorContext(graphP theGraph) void _ClearAllVisitedFlagsInGraph(graphP theGraph) { - _ClearAnyTypeVertexVisitedFlags(theGraph, TRUE); + _ClearVertexVisitedFlags(theGraph, TRUE); _ClearEdgeVisitedFlags(theGraph); } /******************************************************************** - _ClearAnyTypeVertexVisitedFlags() + _ClearVertexVisitedFlags() Clears the visited flags of vertices, and if the second parameter is truthy, also clears the visited flags of virtual vertices. ********************************************************************/ -void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int includeVirtualVertices) +void _ClearVertexVisitedFlags(graphP theGraph, int includeVirtualVertices) { - int v; - - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (int v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) gp_ClearVisited(theGraph, v); if (includeVirtualVertices) - for (v = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, v); v++) - gp_ClearVisited(theGraph, v); + for (int vv = gp_LowerBoundVirtualVertices(theGraph); vv < gp_UpperBoundVirtualVertices(theGraph); ++vv) + gp_ClearVisited(theGraph, vv); } /******************************************************************** @@ -602,10 +563,7 @@ void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int includeVirtualVertices void _ClearEdgeVisitedFlags(graphP theGraph) { - int e, EsizeOccupied; - - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e++) + for (int e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); ++e) gp_ClearEdgeVisited(theGraph, e); } @@ -664,7 +622,7 @@ int _ClearAllVisitedFlagsInOtherBicomps(graphP theGraph, int BicompRoot) { int R; - for (R = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, R); R++) + for (R = gp_LowerBoundVirtualVertices(theGraph); R < gp_UpperBoundVirtualVertices(theGraph); ++R) { if (R != BicompRoot && gp_VirtualVertexInUse(theGraph, R)) { @@ -685,7 +643,7 @@ void _ClearEdgeVisitedFlagsInUnembeddedEdges(graphP theGraph) { int v, e; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { e = gp_GetVertexFwdEdgeList(theGraph, v); while (gp_IsEdge(theGraph, e)) @@ -871,11 +829,6 @@ void _ClearGraph(graphP theGraph) free(theGraph->V); theGraph->V = NULL; } - if (theGraph->VI != NULL) - { - free(theGraph->VI); - theGraph->V = NULL; - } if (theGraph->E != NULL) { free(theGraph->E); @@ -886,25 +839,49 @@ void _ClearGraph(graphP theGraph) theGraph->NV = 0; theGraph->M = 0; theGraph->edgeCapacity = 0; - theGraph->graphFlags = 0; theGraph->embedFlags = 0; - _InitIsolatorContext(theGraph); - - LCFree(&theGraph->BicompRootLists); - LCFree(&theGraph->sortedDFSChildLists); + sp_Free(&theGraph->edgeHoles); + theGraph->numEdgeHoles = 0; sp_Free(&theGraph->theStack); + LCFree(&theGraph->BicompRootLists); + if (theGraph->DVI != NULL) + { + free(theGraph->DVI); + theGraph->DVI = NULL; + } + if (theGraph->PVI != NULL) + { + free(theGraph->PVI); + theGraph->PVI = NULL; + } + LCFree(&theGraph->sortedDFSChildLists); if (theGraph->extFace != NULL) { free(theGraph->extFace); theGraph->extFace = NULL; } - - sp_Free(&theGraph->edgeHoles); + if (theGraph->IC != NULL) + { + free(theGraph->IC); + theGraph->IC = NULL; + } gp_FreeExtensions(theGraph); + + // Free the pseudo-extensions + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY) + gp_Detach_Outerplanarity(theGraph); + + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_PLANARITY) + gp_Detach_Planarity(theGraph); + + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_DFSUTILS) + gp_Detach_DFSUtils(theGraph); + + theGraph->graphFlags = 0; } /******************************************************************** @@ -922,6 +899,12 @@ void gp_Free(graphP *pGraph) _ClearGraph(*pGraph); + if ((*pGraph)->functions != NULL) + { + free((*pGraph)->functions); + (*pGraph)->functions = NULL; + } + free(*pGraph); *pGraph = NULL; } @@ -940,7 +923,7 @@ void gp_Free(graphP *pGraph) ********************************************************************/ int gp_CopyAdjacencyLists(graphP dstGraph, graphP srcGraph) { - int v, e, EsizeOccupied; + int v, e; if (dstGraph == NULL || srcGraph == NULL) return NOTOK; @@ -952,15 +935,14 @@ int gp_CopyAdjacencyLists(graphP dstGraph, graphP srcGraph) return NOTOK; // Copy the links that hook each owning vertex to its adjacency list - for (v = gp_GetFirstVertex(srcGraph); gp_VertexInRangeAscending(srcGraph, v); v++) + for (v = gp_LowerBoundVertices(srcGraph); v < gp_UpperBoundVertices(srcGraph); ++v) { gp_SetFirstEdge(dstGraph, v, gp_GetFirstEdge(srcGraph, v)); gp_SetLastEdge(dstGraph, v, gp_GetLastEdge(srcGraph, v)); } // Copy the adjacency links and neighbor pointers for each edge record - EsizeOccupied = gp_EdgeInUseArraySize(srcGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e++) + for (e = gp_LowerBoundEdges(srcGraph); e < gp_UpperBoundEdges(srcGraph); ++e) { gp_SetNeighbor(dstGraph, e, gp_GetNeighbor(srcGraph, e)); gp_SetNextEdge(dstGraph, e, gp_GetNextEdge(srcGraph, e)); @@ -970,6 +952,7 @@ int gp_CopyAdjacencyLists(graphP dstGraph, graphP srcGraph) // Tell the dstGraph how many edges it now has and where the edge holes are dstGraph->M = gp_GetM(srcGraph); sp_Copy(dstGraph->edgeHoles, srcGraph->edgeHoles); + dstGraph->numEdgeHoles = sp_GetCurrentSize(dstGraph->edgeHoles); return OK; } @@ -990,13 +973,14 @@ int gp_CopyAdjacencyLists(graphP dstGraph, graphP srcGraph) ********************************************************************/ // Give macro names to three copy operations -#define _gp_CopyAnyTypeVertexRec(dstGraph, vdst, srcGraph, vsrc) (dstGraph->V[vdst] = srcGraph->V[vsrc]) -#define _gp_CopyVertexInfo(dstGraph, dstI, srcGraph, srcI) (dstGraph->VI[dstI] = srcGraph->VI[srcI]) +#define _gp_CopyVertexRec(dstGraph, vdst, srcGraph, vsrc) (dstGraph->V[vdst] = srcGraph->V[vsrc]) +#define _gp_CopyDFSUtilsVertexInfo(dstGraph, dstI, srcGraph, srcI) (dstGraph->DVI[dstI] = srcGraph->DVI[srcI]) +#define _gp_CopyPlanarityVertexInfo(dstGraph, dstI, srcGraph, srcI) (dstGraph->PVI[dstI] = srcGraph->PVI[srcI]) #define _gp_CopyEdgeRec(dstGraph, edst, srcGraph, esrc) (dstGraph->E[edst] = srcGraph->E[esrc]) int gp_CopyGraph(graphP dstGraph, graphP srcGraph) { - int v, e, Esize; + int v, e; // Parameter checks if (dstGraph == NULL || srcGraph == NULL) @@ -1034,42 +1018,44 @@ int gp_CopyGraph(graphP dstGraph, graphP srcGraph) // Copy the vertices (non-virtual only). Augmentations to vertices created // by extensions are copied below by gp_CopyExtensions() - for (v = gp_GetFirstVertex(srcGraph); gp_VertexInRangeAscending(srcGraph, v); v++) + for (v = gp_LowerBoundVertices(srcGraph); v < gp_UpperBoundVertices(srcGraph); ++v) { - _gp_CopyAnyTypeVertexRec(dstGraph, v, srcGraph, v); - _gp_CopyVertexInfo(dstGraph, v, srcGraph, v); + _gp_CopyVertexRec(dstGraph, v, srcGraph, v); + if (dstGraph->DVI != NULL && srcGraph->DVI != NULL) + _gp_CopyDFSUtilsVertexInfo(dstGraph, v, srcGraph, v); + if (dstGraph->PVI != NULL && srcGraph->PVI != NULL) + _gp_CopyPlanarityVertexInfo(dstGraph, v, srcGraph, v); gp_SetExtFaceVertex(dstGraph, v, 0, gp_GetExtFaceVertex(srcGraph, v, 0)); gp_SetExtFaceVertex(dstGraph, v, 1, gp_GetExtFaceVertex(srcGraph, v, 1)); } // Copy the virtual vertices. Augmentations to virtual vertices created // by extensions are copied below by gp_CopyExtensions() - for (v = gp_GetFirstVirtualVertex(srcGraph); gp_VirtualVertexInRangeAscending(srcGraph, v); v++) + for (v = gp_LowerBoundVirtualVertices(srcGraph); v < gp_UpperBoundVirtualVertices(srcGraph); ++v) { - _gp_CopyAnyTypeVertexRec(dstGraph, v, srcGraph, v); + _gp_CopyVertexRec(dstGraph, v, srcGraph, v); gp_SetExtFaceVertex(dstGraph, v, 0, gp_GetExtFaceVertex(srcGraph, v, 0)); gp_SetExtFaceVertex(dstGraph, v, 1, gp_GetExtFaceVertex(srcGraph, v, 1)); } // Copy the basic EdgeRec structures. Augmentations to the edgeRec structure // created by extensions are copied below by gp_CopyExtensions() - Esize = gp_EdgeArraySize(srcGraph); - for (e = gp_EdgeArrayStart(theGraph); e < Esize; e++) + for (e = gp_LowerBoundEdgeStorage(srcGraph); e < gp_UpperBoundEdgeStorage(srcGraph); e++) _gp_CopyEdgeRec(dstGraph, e, srcGraph, e); // Give the dstGraph the same size and intrinsic properties dstGraph->N = gp_GetN(srcGraph); dstGraph->NV = gp_GetNV(srcGraph); dstGraph->M = gp_GetM(srcGraph); - dstGraph->graphFlags = gp_GetGraphFlags(srcGraph); dstGraph->embedFlags = gp_GetEmbedFlags(srcGraph); - dstGraph->IC = srcGraph->IC; + dstGraph->graphFlags = gp_GetGraphFlags(srcGraph); LCCopy(dstGraph->BicompRootLists, srcGraph->BicompRootLists); LCCopy(dstGraph->sortedDFSChildLists, srcGraph->sortedDFSChildLists); sp_Copy(dstGraph->theStack, srcGraph->theStack); sp_Copy(dstGraph->edgeHoles, srcGraph->edgeHoles); + dstGraph->numEdgeHoles = sp_GetCurrentSize((dstGraph)->edgeHoles); // Copy the set of extensions, which includes copying the // extension data as well as the function overload tables @@ -1080,15 +1066,16 @@ int gp_CopyGraph(graphP dstGraph, graphP srcGraph) // the most recent extension overloads of each function (or // the original function pointer if a particular function has // not been overloaded). + // // This must be done after copying the extension because the - // first step of copying the extensions is to delete the - // dstGraph extensions, which clears its function table. - // Therefore, no good to assign the srcGraph functions *before* - // copying the extensions because the assignment would be wiped out - // This, in turn, means that the DupContext function of an extension - // *cannot* depend on any extension function overloads; the extension - // must directly invoke extension functions only. - dstGraph->functions = srcGraph->functions; + // first step of copying the extensions is to free the extensions + // of the dstGraph, which performs _InitFunctionTable() on dstGraph. + // Therefore, assigning the srcGraph functions to dstGraph *before* + // copying the extensions doesn't work because the assignment would be + // wiped out. This, in turn, means that the DupContext function of an + // extension *cannot* depend on any extension function overloads; + // the extension must directly invoke extension functions only. + *(dstGraph->functions) = *(srcGraph->functions); return OK; } @@ -1138,9 +1125,9 @@ int gp_CreateRandomGraph(graphP theGraph) Also, we are not generating the DFS tree but rather a tree that simply ensures the resulting random graph is connected. */ - for (v = gp_GetFirstVertex(theGraph) + 1; gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph) + 1; v < gp_UpperBoundVertices(theGraph); ++v) { - u = _GetRandomNumber(gp_GetFirstVertex(theGraph), v - 1); + u = _GetRandomNumber(gp_LowerBoundVertices(theGraph), v - 1); if (gp_AddEdge(theGraph, u, 0, v, 0) != OK) return NOTOK; } @@ -1156,8 +1143,8 @@ int gp_CreateRandomGraph(graphP theGraph) for (m = N - 1; m < M; m++) { - u = _GetRandomNumber(gp_GetFirstVertex(theGraph), gp_GetLastVertex(theGraph) - 1); - v = _GetRandomNumber(u + 1, gp_GetLastVertex(theGraph)); + u = _GetRandomNumber(gp_LowerBoundVertices(theGraph), gp_UpperBoundVertices(theGraph) - 2); + v = _GetRandomNumber(u + 1, gp_UpperBoundVertices(theGraph) - 1); // If the edge (u,v) exists, decrement eIndex to try again if (gp_IsNeighbor(theGraph, u, v)) @@ -1274,16 +1261,28 @@ int _hasUnprocessedChild(graphP theGraph, int parent) Given a graph structure with a pre-specified number of vertices N, this function creates a graph with the specified number of edges. - If numEdges <= 3N-6, then the graph generated is planar. If - numEdges is larger, then a maximal planar graph is generated, then - (numEdges - (3N - 6)) additional random edges are added. + The primary use case for this method is to generate either a + maximal planar graph, or a maximal planar graph plus a number + of random additional edges. These cases correspond to the + numEdges being equal to 3N-6 or greater than 3N-6, respectively. + + If numEdges < 3N-6, then the graph generated is a random tree plus + edges added systematically to the tree while maintaining planarity. + The output graph will have at least numEdges edges, but it may have + a few more since more than one edge is added per iteration of the + loop that adds the extra edges to the random tree. This function assumes the caller has already called srand(). ********************************************************************/ int gp_CreateRandomGraphEx(graphP theGraph, int numEdges) { - int N, M, root, v, c, p, last, u, e, EsizeOccupied; + int N, M, root, v, c, p, last, u, e; + + // Parameter checks: Must have a graph of at least three vertices, and the + // number of edges must be at least enough to support making a random tree. + if (theGraph == NULL || gp_GetN(theGraph) < 3 || numEdges < (gp_GetN(theGraph) - 1)) + return NOTOK; N = gp_GetN(theGraph); @@ -1292,87 +1291,178 @@ int gp_CreateRandomGraphEx(graphP theGraph, int numEdges) /* Generate a random tree. */ - for (v = gp_GetFirstVertex(theGraph) + 1; gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph) + 1; v < gp_UpperBoundVertices(theGraph); ++v) { - u = _GetRandomNumber(gp_GetFirstVertex(theGraph), v - 1); + u = _GetRandomNumber(gp_LowerBoundVertices(theGraph), v - 1); if (gp_AddEdge(theGraph, u, 0, v, 0) != OK) return NOTOK; else { e = _gp_FindEdge(theGraph, u, v); - gp_SetEdgeType(theGraph, e, EDGE_TYPE_RANDOMTREE); - gp_SetEdgeType(theGraph, gp_GetTwin(theGraph, e), EDGE_TYPE_RANDOMTREE); + gp_SetEdgeType(theGraph, e, EDGE_TYPE_TREE); + gp_SetEdgeType(theGraph, gp_GetTwin(theGraph, e), EDGE_TYPE_TREE); gp_ClearEdgeVisited(theGraph, e); gp_ClearEdgeVisited(theGraph, gp_GetTwin(theGraph, e)); } } - /* Add edges up to the limit or until the graph is maximal planar. */ + // Start with generating a maxplanar graph on the random tree + // (or adding edges up to numEdges in the fashion of generating a maxplanar graph) M = numEdges <= 3 * N - 6 ? numEdges : 3 * N - 6; - root = gp_GetFirstVertex(theGraph); + // Start with the first vertex + root = gp_LowerBoundVertices(theGraph); + + // Generally, we use v keep track of a traversal down and up all the random tree edges + // The last variable marks the location of the last vertex that was an endpoint of the + // most recently added edge. v = last = _getUnprocessedChild(theGraph, root); + // Just a safety check (all children of root are initially unprocessed) + if (gp_IsNotVertex(theGraph, v)) + return NOTOK; + + // Vertex v starts at the first unprocessed child of root and traverses around both sides + // of the edges of the random tree until it gets back to the root... except, + // The original version of this method generated a maxplanar graph only, but it was + // refactored to give greater control of the number of edges. After the refactor, this + // loop now stops when the edge count reaches M. Even for a maxplanar graph, that will + // happen when v reaches the last unprocessed child of the last unprocessed child of root. + // Still, we test for v != root for greater understanding of the idea of this method. while (v != root && gp_GetM(theGraph) < M) { + // Get the next unprocessed child of v, if any. This method has the side effect + // that it marks the edge (v, c) and hence c as being processed. This method + // returns NIL (which not a vertex) if v has no _unprocessed_ children left. c = _getUnprocessedChild(theGraph, v); + // If v did have an unprocessed child... if (gp_IsVertex(theGraph, c)) { + // FORWARD_LABEL_0 (see below) if (last != v) { if (gp_AddEdge(theGraph, last, 1, c, 1) != OK) return NOTOK; } + // Add an edge to create a new triangular face with root, v, and the child c + // FORWARD_LABEL_1 (see below) if (gp_AddEdge(theGraph, root, 1, c, 1) != OK) return NOTOK; + // Advance the traversal of v to the child c, and also assign c to last because + // (root, c) is the last non-tree edge added. v = last = c; } + // If v did not have any more unprocessed children, then we have to back up to + // the nearest of its tree ancestors that does have an unprocessed child else { + // Get the parent of v and get its next unprocessed child, if any p = gp_GetVertexParent(theGraph, v); - while (gp_IsVertex(theGraph, p) && gp_IsNotVertex(theGraph, (c = _getUnprocessedChild(theGraph, p)))) + if (gp_IsVertex(theGraph, p)) + c = _getUnprocessedChild(theGraph, p); + + // Loop until we find an ancestor (p) of v that does have an unprocessed child + // This loop also creates more triangular faces as it traverses back up along + // the child-to-parent sides of edges to the successive ancestors of v. + // FORWARD_LABEL_2 (see below) + while (gp_IsVertex(theGraph, p) && gp_IsNotVertex(theGraph, (c))) { + // Since we are in this loop, the parent p did not have + // an unprocessed child, so we advance both p and v to + // enable checking the next higher ancestor v = p; p = gp_GetVertexParent(theGraph, v); - if (gp_IsVertex(theGraph, p) && p != root) + + // Now that we have advanced upward, there is now a triangular face + // we can create between the original v (denoted last) and the new + // parent, which is a grandparent or higher of last. + // This ensures that we triangulate along the path leading back + // up to the next vertex with an unprocessed child. + if (gp_IsVertex(theGraph, p)) { - if (gp_AddEdge(theGraph, last, 1, p, 1) != OK) - return NOTOK; + // We exclude adding an edge between last and p in the special case + // that p has ascended back up to the root because adding the edge + // would create a duplicate of the edge added at FORWARD_LABEL_1 + if (p != root) + { + if (gp_AddEdge(theGraph, last, 1, p, 1) != OK) + return NOTOK; + } } + + // Now that we have dealt with triangulation of that path up to the new p, + // we obtain its next unprocessed child, if any to see if we have gone + // to a high enough ancestor that we have an unprocessed child to deal with. + // NOTE: At the very least, there will still be an unprocessed child by the + // time p gets to the tree root because we haven't yet reached the + // edge limit in the outer loop condition. + if (gp_IsVertex(theGraph, p)) + c = _getUnprocessedChild(theGraph, p); } + // Back when v != root was the outer loop condition, it was possible for v to + // go to the root, and for p to become NIL (not a vertex). Now, that the outer + // loop ends as soon as enough edges are added, p is always a vertex. + // Still, we do the test here. if (gp_IsVertex(theGraph, p)) { if (p == root) { + // If p is the root, then we create a triangular face containing + // v, p==root, and c, where v is the last vertex visited in one + // of subtree of p==root, and c is the first vertex visited in the + // next subtree of p== root. + // NOTE: This is a special kind of edge called a "cross edge" that + // joins two vertices that do not have the ancestor-descendant + // relationship (i.e., it is not a "back edge" and so the tree + // is not a DFS tree). if (gp_AddEdge(theGraph, v, 1, c, 1) != OK) return NOTOK; + // If v advanced upward to a higher ancestor than the parent of last, + // then we entered the loop at FORWARD_LABEL_2, which triangulated + // on the way up, except now we must add an edge that creates a + // triangular face with last, v, and c. if (v != last) { if (gp_AddEdge(theGraph, last, 1, c, 1) != OK) return NOTOK; } + + // NOTE: Because p is the root, we do not advance 'last' to c quite yet + // because v will advance to c below and the next iteration of + // the outer loop will get _its_ next unprocessed child, say c2. + // Only once we know the identity of c2 can we add the extra edge + // needed to create a triangular face with last, c, and c2. + // This occurs at FORWARD_LABEL_0 above, with v=c and c=c2, + // after which last is assigned the value c2. + // Perhaps one day enough guilt will accrue to foster doing what + // is needed here to allow c to be assigned to last. } + + // In case p is not the root, then we have already triangulated along the + // path up from last to p, so... else { + // We add an edge that creates a triangular face with last, p, and c. if (gp_AddEdge(theGraph, last, 1, c, 1) != OK) return NOTOK; - } - if (p != root) - { + // And then an edge that creates a triangular face with root, last, and c. if (gp_AddEdge(theGraph, root, 1, c, 1) != OK) return NOTOK; + + // At which point, last can advance to c last = c; } + // The main traversal tracking variable v can now advance to c v = c; } } @@ -1382,8 +1472,8 @@ int gp_CreateRandomGraphEx(graphP theGraph, int numEdges) while (gp_GetM(theGraph) < numEdges) { - u = _GetRandomNumber(gp_GetFirstVertex(theGraph), gp_GetLastVertex(theGraph)); - v = _GetRandomNumber(gp_GetFirstVertex(theGraph), gp_GetLastVertex(theGraph)); + u = _GetRandomNumber(gp_LowerBoundVertices(theGraph), gp_UpperBoundVertices(theGraph) - 1); + v = _GetRandomNumber(gp_LowerBoundVertices(theGraph), gp_UpperBoundVertices(theGraph) - 1); if (u != v && !gp_IsNeighbor(theGraph, u, v)) if (gp_AddEdge(theGraph, u, 0, v, 0) != OK) @@ -1392,8 +1482,7 @@ int gp_CreateRandomGraphEx(graphP theGraph, int numEdges) /* Clear the edge types back to 'unknown' */ - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = 0; e < EsizeOccupied; e++) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); ++e) { gp_ClearEdgeType(theGraph, e); gp_ClearEdgeVisited(theGraph, e); @@ -1401,7 +1490,7 @@ int gp_CreateRandomGraphEx(graphP theGraph, int numEdges) /* Put all DFSParent indicators back to NIL */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) gp_SetVertexParent(theGraph, v, NIL); return OK; @@ -1425,8 +1514,8 @@ int gp_IsNeighbor(graphP theGraph, int u, int v) int e = NIL; if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || u >= gp_AnyTypeVertexArraySize(theGraph) || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph)) + u < gp_LowerBoundVertexStorage(theGraph) || u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) { #ifdef DEBUG NOTOK; @@ -1463,8 +1552,8 @@ int gp_IsNeighborDirected(graphP theGraph, int u, int v, unsigned direction) int e = NIL; if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || u >= gp_AnyTypeVertexArraySize(theGraph) || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph) || + u < gp_LowerBoundVertexStorage(theGraph) || u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph) || (direction != 0 && direction != EDGEFLAG_DIRECTION_INONLY && direction != EDGEFLAG_DIRECTION_OUTONLY)) { #ifdef DEBUG @@ -1504,8 +1593,8 @@ int gp_IsNeighborDirected(graphP theGraph, int u, int v, unsigned direction) int gp_FindEdge(graphP theGraph, int u, int v) { if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || u >= gp_AnyTypeVertexArraySize(theGraph) || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph)) + u < gp_LowerBoundVertexStorage(theGraph) || u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) { #ifdef DEBUG NOTOK; @@ -1556,8 +1645,8 @@ int gp_FindDirectedEdge(graphP theGraph, int u, int v, unsigned direction) int e = NIL; if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || u >= gp_AnyTypeVertexArraySize(theGraph) || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph) || + u < gp_LowerBoundVertexStorage(theGraph) || u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph) || (direction != 0 && direction != EDGEFLAG_DIRECTION_INONLY && direction != EDGEFLAG_DIRECTION_OUTONLY)) { #ifdef DEBUG @@ -1605,7 +1694,7 @@ int gp_GetVertexDegree(graphP theGraph, int v) int e, degree; if (theGraph == NULL || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph)) + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) { #ifdef DEBUG NOTOK; @@ -1645,7 +1734,7 @@ int gp_GetVertexInDegree(graphP theGraph, int v) int e, degree; if (theGraph == NULL || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph)) + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) { #ifdef DEBUG NOTOK; @@ -1685,7 +1774,7 @@ int gp_GetVertexOutDegree(graphP theGraph, int v) int e, degree; if (theGraph == NULL || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph)) + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) { #ifdef DEBUG NOTOK; @@ -1833,10 +1922,9 @@ void _DetachEdgeRecord(graphP theGraph, int e) caller can guard against these conditions by pre-testing that u != v and that gp_FindEdge() returns NIL. - Returns OK on success, NOTOK on failure, NONEMBEDDABLE if adding the - edge would exceed the graph's edge capacity (the caller can - invoke gp_DynamicAddEdge() to avoid the NONEMBEDDABLE result). - + Returns OK on success, NOTOK on failure, or AT_EDGE_CAPACITY_LIMIT if + adding the edge would exceed the graph's edge capacity (the + caller can use gp_DynamicAddEdge()). ********************************************************************/ int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) @@ -1844,21 +1932,22 @@ int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) int upos, vpos; if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || v < gp_GetFirstVertex(theGraph) || - !gp_VirtualVertexInRangeAscending(theGraph, u) || !gp_VirtualVertexInRangeAscending(theGraph, v)) + u < gp_LowerBoundVertexStorage(theGraph) || v < gp_LowerBoundVertexStorage(theGraph) || + u >= gp_UpperBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph)) return NOTOK; /* We enforce the edge limit */ if (gp_GetM(theGraph) >= theGraph->edgeCapacity) - return NONEMBEDDABLE; + return AT_EDGE_CAPACITY_LIMIT; if (sp_NonEmpty(theGraph->edgeHoles)) { sp_Pop(theGraph->edgeHoles, vpos); + theGraph->numEdgeHoles = sp_GetCurrentSize(theGraph->edgeHoles); } else - vpos = gp_EdgeInUseArraySize(theGraph); + vpos = gp_UpperBoundEdges(theGraph); upos = gp_GetTwin(theGraph, vpos); @@ -1873,10 +1962,10 @@ int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) /******************************************************************** gp_DynamicAddEdge() - Refer to documentation for gp_AddEdge for parameter description. + Refer to documentation for gp_AddEdge() for parameter description. - Tries to call gp_AddEdge; if NONEMBEDDABLE, doubles the edge - capacity using gp_EnsureEdgeCapacity, then retries gp_AddEdge. + Calls gp_AddEdge(); if AT_EDGE_CAPACITY_LIMIT, doubles the edge + capacity using gp_EnsureEdgeCapacity(), then retries gp_AddEdge(). Returns OK on success, NOTOK on failure. ********************************************************************/ @@ -1886,7 +1975,7 @@ int gp_DynamicAddEdge(graphP theGraph, int u, int ulink, int v, int vlink) Result = gp_AddEdge(theGraph, u, ulink, v, vlink); - if (Result == NONEMBEDDABLE) + if (Result == AT_EDGE_CAPACITY_LIMIT) { // The candidate edge capacity is double the current capacity int candidateEdgeCapacity = gp_GetEdgeCapacity(theGraph) << 1; @@ -1933,39 +2022,43 @@ int gp_DynamicAddEdge(graphP theGraph, int u, int ulink, int v, int vlink) NOTE: See notes on gp_AddEdge(). - Returns OK on success, NOTOK on failure, NONEMBEDDABLE if adding the - edge would exceed the graph's edge capacity (the caller can - invoke gp_EnsureEdgeCapacity() ahead of time to avoid the - NONEMBEDDABLE result). + Returns OK on success, NOTOK on failure, or AT_EDGE_CAPACITY_LIMIT if + adding the edge would exceed the graph's edge capacity (the + caller can invoke gp_EnsureEdgeCapacity() beforehand to avoid + an AT_EDGE_CAPACITY_LIMIT result). ********************************************************************/ int gp_InsertEdge(graphP theGraph, int u, int e_u, int e_ulink, int v, int e_v, int e_vlink) { - int vertMax, edgeMax, upos, vpos; + int upos, vpos; if (theGraph == NULL) return NOTOK; - vertMax = gp_GetLastVirtualVertex(theGraph); - edgeMax = gp_EdgeInUseArraySize(theGraph) - 1; - - if (u < gp_GetFirstVertex(theGraph) || u > vertMax || - v < gp_GetFirstVertex(theGraph) || v > vertMax || - e_u > edgeMax || (e_u < gp_EdgeArrayStart(theGraph) && gp_IsEdge(theGraph, e_u)) || - e_v > edgeMax || (e_v < gp_EdgeArrayStart(theGraph) && gp_IsEdge(theGraph, e_v)) || + if (u < gp_LowerBoundVertexStorage(theGraph) || + u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || + v >= gp_UpperBoundVertexStorage(theGraph) || + (e_u < gp_LowerBoundEdges(theGraph) && gp_IsEdge(theGraph, e_u)) || + e_u >= gp_UpperBoundEdges(theGraph) || + (gp_IsEdge(theGraph, e_u) && gp_EdgeNotInUse(theGraph, e_u)) || + (e_v < gp_LowerBoundEdges(theGraph) && gp_IsEdge(theGraph, e_v)) || + e_v >= gp_UpperBoundEdges(theGraph) || + (gp_IsEdge(theGraph, e_v) && gp_EdgeNotInUse(theGraph, e_v)) || e_ulink < 0 || e_ulink > 1 || e_vlink < 0 || e_vlink > 1) return NOTOK; if (gp_GetM(theGraph) >= theGraph->edgeCapacity) - return NONEMBEDDABLE; + return AT_EDGE_CAPACITY_LIMIT; if (sp_NonEmpty(theGraph->edgeHoles)) { sp_Pop(theGraph->edgeHoles, vpos); + theGraph->numEdgeHoles = sp_GetCurrentSize(theGraph->edgeHoles); } else - vpos = gp_EdgeInUseArraySize(theGraph); + vpos = gp_UpperBoundEdges(theGraph); // NOTE: We do not _InitEdgeRec() nor gp_InitEdgeFlags() here because // the vpos edge location is expected to be in initialized state, @@ -2006,7 +2099,8 @@ int gp_InsertEdge(graphP theGraph, int u, int e_u, int e_ulink, int gp_DeleteEdge(graphP theGraph, int e) { if (theGraph == NULL || - e < gp_EdgeArrayStart(theGraph) || e >= gp_EdgeInUseArraySize(theGraph) || + e < gp_LowerBoundEdges(theGraph) || + e >= gp_UpperBoundEdges(theGraph) || gp_EdgeNotInUse(theGraph, e)) return NOTOK; @@ -2016,7 +2110,7 @@ int gp_DeleteEdge(graphP theGraph, int e) // Clear the two edge records // (the bit twiddle (e & ~1) chooses the lesser of e and its twin) -#ifdef USE_FASTER_1BASEDARRAYS +#ifdef USE_1BASEDARRAYS memset(theGraph->E + (e & ~1), NIL_CHAR, sizeof(edgeRec) << 1); #else _InitEdgeRec(theGraph, e); @@ -2028,12 +2122,13 @@ int gp_DeleteEdge(graphP theGraph, int e) // If records e and eTwin were not the last in the edge record array, // then record a new hole in the edge array. */ - if (e < gp_EdgeInUseArraySize(theGraph)) + if (e < gp_UpperBoundEdges(theGraph)) { if (theGraph->edgeHoles->size + 1 >= theGraph->edgeHoles->capacity) return NOTOK; sp_Push(theGraph->edgeHoles, e); + theGraph->numEdgeHoles = sp_GetCurrentSize(theGraph->edgeHoles); } // Return the previously calculated successor of e. @@ -2086,7 +2181,7 @@ void _RestoreEdgeRecord(graphP theGraph, int e) void gp_HideEdge(graphP theGraph, int e) { if (theGraph == NULL || - e < gp_EdgeArrayStart(theGraph) || e >= gp_EdgeInUseArraySize(theGraph) || + e < gp_LowerBoundEdges(theGraph) || e >= gp_UpperBoundEdges(theGraph) || gp_EdgeNotInUse(theGraph, e)) { #ifdef DEBUG @@ -2095,7 +2190,7 @@ void gp_HideEdge(graphP theGraph, int e) return; } - theGraph->functions.fpHideEdge(theGraph, e); + theGraph->functions->fpHideEdge(theGraph, e); } void _HideEdge(graphP theGraph, int e) @@ -2124,7 +2219,7 @@ void _HideEdge(graphP theGraph, int e) void gp_RestoreEdge(graphP theGraph, int e) { if (theGraph == NULL || - e < gp_EdgeArrayStart(theGraph) || e >= gp_EdgeInUseArraySize(theGraph) || + e < gp_LowerBoundEdges(theGraph) || e >= gp_UpperBoundEdges(theGraph) || gp_EdgeNotInUse(theGraph, e)) { #ifdef DEBUG @@ -2133,7 +2228,7 @@ void gp_RestoreEdge(graphP theGraph, int e) return; } - theGraph->functions.fpRestoreEdge(theGraph, e); + theGraph->functions->fpRestoreEdge(theGraph, e); } void _RestoreEdge(graphP theGraph, int e) @@ -2232,12 +2327,12 @@ int _RestoreHiddenEdges(graphP theGraph, int stackBottom) int gp_HideVertex(graphP theGraph, int vertex) { if (theGraph == NULL || - vertex < gp_GetFirstVertex(theGraph) || vertex >= gp_AnyTypeVertexArraySize(theGraph)) + vertex < gp_LowerBoundVertexStorage(theGraph) || vertex >= gp_UpperBoundVertexStorage(theGraph)) { return NOTOK; } - return theGraph->functions.fpHideVertex(theGraph, vertex); + return theGraph->functions->fpHideVertex(theGraph, vertex); } int _HideVertex(graphP theGraph, int vertex) @@ -2278,13 +2373,13 @@ int _HideVertex(graphP theGraph, int vertex) int gp_ContractEdge(graphP theGraph, int e) { if (theGraph == NULL || - e < gp_EdgeArrayStart(theGraph) || e >= gp_EdgeInUseArraySize(theGraph) || + e < gp_LowerBoundEdges(theGraph) || e >= gp_UpperBoundEdges(theGraph) || gp_EdgeNotInUse(theGraph, e)) { return NOTOK; } - return theGraph->functions.fpContractEdge(theGraph, e); + return theGraph->functions->fpContractEdge(theGraph, e); } int _ContractEdge(graphP theGraph, int e) @@ -2342,16 +2437,16 @@ int _ContractEdge(graphP theGraph, int e) int gp_IdentifyVertices(graphP theGraph, int u, int v, int eBefore) { if (theGraph == NULL || - u < gp_GetFirstVertex(theGraph) || u >= gp_AnyTypeVertexArraySize(theGraph) || - v < gp_GetFirstVertex(theGraph) || v >= gp_AnyTypeVertexArraySize(theGraph) || - (eBefore != NIL && eBefore < gp_EdgeArrayStart(theGraph)) || - eBefore >= gp_EdgeInUseArraySize(theGraph) || + u < gp_LowerBoundVertexStorage(theGraph) || u >= gp_UpperBoundVertexStorage(theGraph) || + v < gp_LowerBoundVertexStorage(theGraph) || v >= gp_UpperBoundVertexStorage(theGraph) || + (eBefore != NIL && eBefore < gp_LowerBoundEdges(theGraph)) || + eBefore >= gp_UpperBoundEdges(theGraph) || (eBefore != NIL && gp_EdgeNotInUse(theGraph, eBefore))) { return NOTOK; } - return theGraph->functions.fpIdentifyVertices(theGraph, u, v, eBefore); + return theGraph->functions->fpIdentifyVertices(theGraph, u, v, eBefore); } int _IdentifyVertices(graphP theGraph, int u, int v, int eBefore) @@ -2534,7 +2629,7 @@ int gp_RestoreVertex(graphP theGraph) if (theGraph == NULL) return NOTOK; - return theGraph->functions.fpRestoreVertex(theGraph); + return theGraph->functions->fpRestoreVertex(theGraph); } int _RestoreVertex(graphP theGraph) @@ -2827,26 +2922,3 @@ int _GetBicompSize(graphP theGraph, int BicompRoot) } return theSize; } - -/******************************************************************** - debugNOTOK() - - This function returns the literal value of NOTOK. In debug mode, - NOTOK is redefined to first use printf() to emit information about - where in the code a NOTOK has occurred. Then, this method is invoked - so that the debug version of NOTOK still returns the NOTOK value. - - Rather than just returning 0 in the debug-mode NOTOK macro, we - invoke this method because it gives the option (with recompilation) - of having the program exit on the first NOTOK occurrence. That - option is off by default, so we normally get a stack trace of the - NOTOK occcurences, but on an exhaustive, long-run test, it can be - handy to stop on the first error since otherwise the error message - might not be seen. - ********************************************************************/ - -int debugNOTOK(void) -{ - // exit(-1); - return 0; // NOTOK is normally defined to be zero -} diff --git a/planarity/c/graphLib/graph.h b/planarity/c/graphLib/graph.h index 1438fe8..fd3e0e1 100644 --- a/planarity/c/graphLib/graph.h +++ b/planarity/c/graphLib/graph.h @@ -12,39 +12,35 @@ extern "C" { #endif -#include "graphStructures.h" - -#include "io/g6-read-iterator.h" -#include "io/g6-write-iterator.h" - -// Headers needed within library but not part of public API -#include "io/strbuf.h" -#include "io/strOrFile.h" - -#include "extensionSystem/graphExtensions.h" +// Basic declarations, such as for OK, NOTOK, and NIL +#include "lowLevelUtils/appconst.h" /////////////////////////////////////////////////////////////////////////////// - // Definitions for higher-order operations at the vertex, edge and graph levels + // The top-level operations at the graph, vertex, and edge levels /////////////////////////////////////////////////////////////////////////////// + // Forward declaration of graph structure and graph pointer type definitions + // (see the end of this header file). + typedef struct graphStruct graphStruct; + typedef graphStruct *graphP; + // Methods related to graph allocation, initialization, and destruction graphP gp_New(void); int gp_InitGraph(graphP theGraph, int N); - void gp_ReinitializeGraph(graphP theGraph); + void gp_ReinitGraph(graphP theGraph); void gp_Free(graphP *pGraph); int gp_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity); -// Basic graph structure interrogators +#define gp_GetEdgeCapacity(theGraph) ((theGraph)->edgeCapacity) + // N=# of vertices; NV=# of virtual vertices; M=# of edges #define gp_GetN(theGraph) ((theGraph)->N) #define gp_GetNV(theGraph) ((theGraph)->NV) #define gp_GetM(theGraph) ((theGraph)->M) -#define gp_GetEdgeCapacity(theGraph) ((theGraph)->edgeCapacity) - // Basic graph utility methods int gp_CopyGraph(graphP dstGraph, graphP srcGraph); graphP gp_DupGraph(graphP theGraph); @@ -53,18 +49,7 @@ extern "C" int gp_CreateRandomGraph(graphP theGraph); int gp_CreateRandomGraphEx(graphP theGraph, int numEdges); - // Basic graph I/O methods - int gp_Read(graphP theGraph, char const *FileName); - int gp_ReadFromString(graphP theGraph, char *inputStr); - - int gp_Write(graphP theGraph, char const *FileName, int Mode); - int gp_WriteToString(graphP theGraph, char **pOutputStr, int Mode); - -// Mode values for gp_Write() and gp_WriteToString() -#define WRITE_ADJLIST 1 -#define WRITE_ADJMATRIX 2 -#define WRITE_DEBUGINFO 3 -#define WRITE_G6 4 + // Basic graph I/O methods: see graphIO.h // Basic vertex interrogators int gp_IsNeighbor(graphP theGraph, int u, int v); @@ -96,53 +81,476 @@ extern "C" int gp_IdentifyVertices(graphP theGraph, int u, int v, int eBefore); int gp_RestoreVertices(graphP theGraph); - // DFS-related methods - int gp_CreateDFSTree(graphP theGraph); - int gp_SortVertices(graphP theGraph); - int gp_ComputeLowpoints(graphP theGraph); - int gp_ComputeLeastAncestors(graphP theGraph); - -/* Graph Flags: - FLAGS_DFSNUMBERED is set if DFS numbering has been performed on the graph - FLAGS_SORTEDBYDFI records whether the graph is in original vertex order - or sorted by depth first index. Successive calls to SortVertices() - toggle this bit. - FLAGS_ZEROBASEDIO is typically set by gp_Read() to indicate that the - adjacency list representation in a file began with index 0. + // For methods and declarations related to depth-first search (DFS), see graphDFSUtils.h + +/* Graph Flags (bit flags set by various public graphLib APIs): + Bits 0-3 reserved for base graph class + Bits 4-7 reserved for graph I/O + Bits 8-15 reserved for DFS Utils + Bits 16-23 reserved for Planarity-Related + bits 24-31 reserved for future expansion */ #define gp_GetGraphFlags(theGraph) ((theGraph)->graphFlags) -#define FLAGS_DFSNUMBERED 1 -#define FLAGS_SORTEDBYDFI 2 -#define FLAGS_ZEROBASEDIO 4 - - // Graph embedding and result validation methods - // The embedResult output by gp_Embed() and input to gp_TestEmbedResultIntegrity() - // can be OK if the graph is embedded or embeddable, NONEMBEDDABLE if a minimal - // subgraph obstructing embedding has been isolated, or NOTOK on error - int gp_Embed(graphP theGraph, int embedFlags); - int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResult); - -/* Possible graph embedFlags for gp_Embed(). - The planar and outerplanar settings are supported natively; - The rest are supported via extension modules. -*/ -#define gp_GetEmbedFlags(theGraph) ((theGraph)->embedFlags) -#define EMBEDFLAGS_PLANAR 1 -#define EMBEDFLAGS_OUTERPLANAR 2 + // For graph embedding methods and declarations, see graphPlanarity.h + +// The initial setting for the edge storage capacity expressed as a constant factor of N, +// which is the number of vertices in the graph. By default, array E is allocated enough +// space to contain 3N edges, which is 6N edge records, but this initial setting +// can be overridden using gp_EnsureEdgeCapacity(). It is especially efficient to change +// to ensure a higher edge capacity if done before calling gp_InitGraph() or gp_Read(). +#define DEFAULT_EDGE_CAPACITY_FACTOR 3 + +// This value is returned by gp_AddEdge() and gp_InsertEdge() if adding or inserting +// the edge would exceed the edge capacity limit. The limit can be increased by +// calling gp_EnsureEdgeCapacity(), or by calling gp_DynamicAddEdge(). +#define AT_EDGE_CAPACITY_LIMIT -1 + + /******************************************************************** + Edge Record Definition + + An edge is defined by a pair of edge records allocated in array E + of a graph. A pair of edge records represents the edge in the + adjacency lists of each vertex to which the edge is incident. + + link[2]: the next and previous edge records in the adjacency + list that contains this edge record. + + v: The vertex neighbor of the vertex whose adjacency list contains + this edge record (an index into array V). + + flags: Bits 0-15 reserved for library; bits 16 and higher for apps + Bit 0: Visited + Bit 1: Marked (2nd visited flag, for while visiting all) + Bit 2: DFS type has been set, versus not set + Bit 3: DFS tree edge, versus cycle edge (co-tree edge, etc.) + Bit 4: DFS edge pointing to descendant, versus to ancestor + Bit 5: Inverted (same as marking an edge with a "sign" of -1) + Bit 6: Edge record is directed into the containing vertex only + Bit 7: Edge record is directed from the containing vertex only + ********************************************************************/ + + struct edgeRec + { + int link[2]; + int neighbor; + unsigned flags; + }; + + typedef struct edgeRec edgeRec; + typedef edgeRec *edgeRecP; + +/*********************************************/ +#ifdef USE_1BASEDARRAYS +/*********************************************/ + +// These lower and upper bounds for edge storage are used for initializing and for +// iterating through all of the edge storage, including space not yet containing edges. +#define gp_LowerBoundEdgeStorage(theGraph) (2) +#define gp_UpperBoundEdgeStorage(theGraph) (gp_LowerBoundEdgeStorage(theGraph) + ((theGraph)->edgeCapacity << 1)) + +// Test whether an index e indicates a valid edge storage location +// (versus NIL in non-debug, or including bounds checking in DEBUG mode +#define gp_IsEdge(theGraph, e) (e) +#define gp_IsNotEdge(theGraph, e) (!(e)) + +#ifdef DEBUG +#undef gp_IsEdge +#define gp_IsEdge(theGraph, e) \ + ((e) == NIL \ + ? 0 \ + : ((e) < gp_LowerBoundEdgeStorage(theGraph) || (e) >= gp_UpperBoundEdgeStorage(theGraph) \ + ? (NOTOK, 0) \ + : 1)) +#endif + +// Given a valid edge record storage index e, we test whether e is in use by an +// existing edge by testing whether or not it indicates a neighbor vertex (versus NIL) +// This test is needed to avoid edge index holes created by gp_DeleteEdge()). +#define gp_EdgeInUse(theGraph, e) (gp_GetNeighbor(theGraph, e)) +#define gp_EdgeNotInUse(theGraph, e) (!gp_GetNeighbor(theGraph, e)) + +/*********************************************/ +#else /* When using 0-based Arrays ***********/ +/*********************************************/ +#define gp_LowerBoundEdgeStorage(theGraph) (0) +#define gp_UpperBoundEdgeStorage(theGraph) (gp_LowerBoundEdgeStorage(theGraph) + ((theGraph)->edgeCapacity << 1)) + +#define gp_IsEdge(theGraph, e) ((e) != NIL) +#define gp_IsNotEdge(theGraph, e) ((e) == NIL) + +#ifdef DEBUG +#undef gp_IsEdge +#define gp_IsEdge(theGraph, e) \ + ((e) == NIL \ + ? 0 \ + : ((e) < gp_LowerBoundEdgeStorage(theGraph) || (e) >= gp_UpperBoundEdgeStorage(theGraph) \ + ? (NOTOK, 0) \ + : 1)) +#endif + +#define gp_EdgeInUse(theGraph, e) (gp_GetNeighbor(theGraph, e) != NIL) +#define gp_EdgeNotInUse(theGraph, e) (!gp_GetNeighbor(theGraph, e) == NIL) +/*********************************************/ +#endif /* End of macros for 0-based Arrays ***/ +/*********************************************/ + +// Lower and upper edge bounds methods are used to test whether a given valid +// edge storage location falls within the range of locations occupied by edges +// of the graph. May be used in combination with gp_EdgeInUse(). +#define gp_LowerBoundEdges(theGraph) (gp_LowerBoundEdgeStorage(theGraph)) +#define gp_UpperBoundEdges(theGraph) (gp_LowerBoundEdges(theGraph) + ((gp_GetM(theGraph) + (theGraph)->numEdgeHoles) << 1)) + +// An edge is represented by two consecutive edge records in the edge array E. +// If an even number, xor 1 will add one; if an odd number, xor 1 will subtract 1 +#define gp_GetTwin(theGraph, e) ((e) ^ 1) + +// Access to adjacency list pointers +#define gp_GetNextEdge(theGraph, e) (theGraph->E[e].link[0]) +#define gp_GetPrevEdge(theGraph, e) (theGraph->E[e].link[1]) +#define gp_GetAdjacentEdge(theGraph, e, theLink) (theGraph->E[e].link[theLink]) + +#define gp_SetNextEdge(theGraph, e, newNextEdge) (theGraph->E[e].link[0] = newNextEdge) +#define gp_SetPrevEdge(theGraph, e, newPrevEdge) (theGraph->E[e].link[1] = newPrevEdge) +#define gp_SetAdjacentEdge(theGraph, e, theLink, newEdge) (theGraph->E[e].link[theLink] = newEdge) + +// Get/set 'neighbor' member indicated by edge record e +#define gp_GetNeighbor(theGraph, e) (theGraph->E[e].neighbor) +#define gp_SetNeighbor(theGraph, e, v) (theGraph->E[e].neighbor = v) + +// Initializer for edge flags +#define gp_InitEdgeFlags(theGraph, e) (theGraph->E[e].flags = 0) + +// Definitions of and access to edge flags +#define EDGE_VISITED_MASK 1 +#define gp_GetEdgeVisited(theGraph, e) (theGraph->E[e].flags & EDGE_VISITED_MASK) +#define gp_ClearEdgeVisited(theGraph, e) (theGraph->E[e].flags &= ~EDGE_VISITED_MASK) +#define gp_SetEdgeVisited(theGraph, e) (theGraph->E[e].flags |= EDGE_VISITED_MASK) + +// Definition and accessors for the edge marked flag +// Essentially, this is a second visitation flag that can help applications that +// must visit all edges to analyze and mark the ones important for some purpose. +#define EDGE_MARKED_MASK 2 +#define gp_GetEdgeMarked(theGraph, e) (theGraph->E[e].flags & EDGE_MARKED_MASK) +#define gp_ClearEdgeMarked(theGraph, e) (theGraph->E[e].flags &= ~EDGE_MARKED_MASK) +#define gp_SetEdgeMarked(theGraph, e) (theGraph->E[e].flags |= EDGE_MARKED_MASK) + +// The edge type is defined by bits 2-4, 4+8+16=28 +#define EDGE_TYPE_MASK 28 + +// Call gp_GetEdgeType(), then compare to one of these four possibilities +// EDGE_TYPE_CHILD - edge record points to a neighboring DFS child +// EDGE_TYPE_FORWARD - edge record points to a DFS descendant, not a DFS child +// EDGE_TYPE_PARENT - edge record points to the DFS parent +// EDGE_TYPE_BACK - edge record points to a DFS ancestor, not the DFS parent +// NOTE: A parent/child tree edge has bit 3 (8) set, forward/back edges do not +#define EDGE_TYPE_CHILD 28 +#define EDGE_TYPE_FORWARD 20 +#define EDGE_TYPE_PARENT 12 +#define EDGE_TYPE_BACK 4 + +// EDGE_TYPE_NOTDEFINED - the edge record type has not been defined +// EDGE_TYPE_TREE - edge record is part of a randomly generated tree +// NOTE: EDGE_TYPE_TREE uses the same bit 3 as DFS parent and child edges above +#define EDGE_TYPE_NOTDEFINED 0 +#define EDGE_TYPE_TREE 8 + +#define gp_GetEdgeType(theGraph, e) (theGraph->E[e].flags & EDGE_TYPE_MASK) +#define gp_ClearEdgeType(theGraph, e) (theGraph->E[e].flags &= ~EDGE_TYPE_MASK) +#define gp_SetEdgeType(theGraph, e, type) (theGraph->E[e].flags |= type) +#define gp_ResetEdgeType(theGraph, e, type) \ + (theGraph->E[e].flags = (theGraph->E[e].flags & ~EDGE_TYPE_MASK) | type) + +#define EDGEFLAG_INVERTED_MASK 32 +#define gp_GetEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags & EDGEFLAG_INVERTED_MASK) +#define gp_SetEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags |= EDGEFLAG_INVERTED_MASK) +#define gp_ClearEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags &= (~EDGEFLAG_INVERTED_MASK)) +#define gp_XorEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags ^= EDGEFLAG_INVERTED_MASK) + +#define EDGEFLAG_DIRECTION_INONLY 64 +#define EDGEFLAG_DIRECTION_OUTONLY 128 +#define EDGEFLAG_DIRECTION_MASK 192 + +// Returns the direction, if any, of the edge record +#define gp_GetDirection(theGraph, e) (theGraph->E[e].flags & EDGEFLAG_DIRECTION_MASK) + +// A direction of 0 clears directedness. Otherwise, edge record e is set +// to direction and e's twin edge record is set to the opposing setting. +#define gp_SetDirection(theGraph, e, direction) \ + { \ + if (direction == EDGEFLAG_DIRECTION_INONLY) \ + { \ + theGraph->E[e].flags |= EDGEFLAG_DIRECTION_INONLY; \ + theGraph->E[gp_GetTwin(theGraph, e)].flags |= EDGEFLAG_DIRECTION_OUTONLY; \ + } \ + else if (direction == EDGEFLAG_DIRECTION_OUTONLY) \ + { \ + theGraph->E[e].flags |= EDGEFLAG_DIRECTION_OUTONLY; \ + theGraph->E[gp_GetTwin(theGraph, e)].flags |= EDGEFLAG_DIRECTION_INONLY; \ + } \ + else \ + { \ + theGraph->E[e].flags &= ~EDGEFLAG_DIRECTION_MASK; \ + theGraph->E[gp_GetTwin(theGraph, e)].flags &= ~EDGEFLAG_DIRECTION_MASK; \ + } \ + } + + /******************************************************************** + Vertex Record Definition (For non-virtual and virtual vertices) + + This record definition provides the data members needed for the + core structural information for both vertices and virtual vertices. + Non-virtual vertices are also equipped with additional information + provided by private vertexInfo records. + + The vertices of a graph are stored in the first N locations of array V. + Virtual vertices are secondary vertices used to help represent the + main vertices in substructural components of a graph (such as in + biconnected components). + + link[2]: the first and last edge records in the adjacency list + of the vertex. + + index: In vertices, stores either the depth first index of a vertex or + the original array index of the vertex if the vertices of the + graph are sorted by DFI. + In virtual vertices, the index may be used to indicate the vertex + that the virtual vertex represents, unless an algorithm has some + other way of making the association (for example, the planarity + algorithms rely on biconnected components and therefore place + virtual vertices of a vertex at positions corresponding to the + DFS children of the vertex). + + flags: Bits 0-15 reserved for library; bits 16 and higher for apps + Bit 0: visited, for vertices and virtual vertices + Bit 1: marked, 2nd visited flag, for while visiting all + Used in K4 homeomorph search algorithm + Bit 2: Obstruction type VERTEX_TYPE_SET (versus not set, i.e. VERTEX_TYPE_UNKNOWN) + Bit 3: Obstruction type qualifier RYW (set) versus RXW (clear) + Bit 4: Obstruction type qualifier high (set) versus low (clear) + Bits 2-4 used in planarity-related algorithms + ********************************************************************/ + + struct vertexRec + { + int link[2]; + int index; + unsigned flags; + }; + + typedef struct vertexRec vertexRec; + typedef vertexRec *vertexRecP; + +//////////////////////////////////////////// +// Accessors for vertex adjacency list links +//////////////////////////////////////////// +#define gp_GetFirstEdge(theGraph, v) (theGraph->V[v].link[0]) +#define gp_GetLastEdge(theGraph, v) (theGraph->V[v].link[1]) +#define gp_GetEdgeByLink(theGraph, v, theLink) (theGraph->V[v].link[theLink]) + +#define gp_SetFirstEdge(theGraph, v, newFirstEdge) (theGraph->V[v].link[0] = newFirstEdge) +#define gp_SetLastEdge(theGraph, v, newLastEdge) (theGraph->V[v].link[1] = newLastEdge) +#define gp_SetEdgeByLink(theGraph, v, theLink, newEdge) (theGraph->V[v].link[theLink] = newEdge) + +/////////////////////////////////// +// Vertex iteration-related methods +/////////////////////////////////// + +// These lower and upper bounds for vertex storage are used for initializing and for +// iterating through all of non-virtual and virtual vertex records. +#ifdef USE_1BASEDARRAYS +#define gp_LowerBoundVertexStorage(theGraph) (1) +#else +#define gp_LowerBoundVertexStorage(theGraph) (0) +#endif -#define EMBEDFLAGS_DRAWPLANAR (4 | EMBEDFLAGS_PLANAR) +#define gp_UpperBoundVertexStorage(theGraph) (gp_LowerBoundVertexStorage(theGraph) + gp_GetN(theGraph) + gp_GetNV(theGraph)) + +// The original N non-virtual vertices of a graph start at the lowest allowed storage location. +// The upper bound is one-past-the-end of the storage for the N non-virtual vertices. +#define gp_LowerBoundVertices(theGraph) gp_LowerBoundVertexStorage(theGraph) +#define gp_UpperBoundVertices(theGraph) (gp_LowerBoundVertexStorage(theGraph) + gp_GetN(theGraph)) + +// The virtual vertices start at the one-past-the-end upper bound of the non-virtual vertices. +// The upper bound is one-past-the-end of the vertex storage locations. +#define gp_LowerBoundVirtualVertices(theGraph) gp_UpperBoundVertices(theGraph) +#define gp_UpperBoundVirtualVertices(theGraph) gp_UpperBoundVertexStorage(theGraph) + +#ifdef USE_1BASEDARRAYS +// The use of *Vertex* alone consistently refers to the initial N vertices. +// The use of *VirtualVertex* refers to vertex array locations after the first N. +#ifndef DEBUG +#define gp_IsVertex(theGraph, v) (v) +#define gp_IsVirtualVertex(theGraph, v) ((v) > gp_GetN(theGraph)) +#else +// See below for definitions common to 1-based and 0-based +#endif -#define EMBEDFLAGS_SEARCHFORK23 (8 | EMBEDFLAGS_OUTERPLANAR) -#define EMBEDFLAGS_SEARCHFORK33 (16 | EMBEDFLAGS_PLANAR) -#define EMBEDFLAGS_SEARCHFORK4 (32 | EMBEDFLAGS_OUTERPLANAR) +#else // Using 0-based Arrays +#ifndef DEBUG +#define gp_IsVertex(theGraph, v) ((v) != NIL) +#define gp_IsVirtualVertex(theGraph, v) ((v) >= gp_GetN(theGraph)) +#else +// See below for definitions common to 1-based and 0-based +#endif +#endif // End of 0-based Arrays + +// The same for 1-based and 0-based when debugging +#ifdef DEBUG +#define gp_IsVertex(theGraph, v) \ + ((v) == NIL ? 0 : ((v) < gp_LowerBoundVertices(theGraph) ? (NOTOK, 0) : ((v) >= gp_UpperBoundVertices(theGraph) ? (NOTOK, 0) : 1))) + +// NOTE: gp_IsVirtualVertex() is sometimes called to distinguish between +// an existing non-virtual and a virtual +#define gp_IsVirtualVertex(theGraph, v) \ + ((v) == NIL \ + ? 0 \ + : ((v) < gp_LowerBoundVirtualVertices(theGraph) \ + ? ((v) < gp_LowerBoundVertices(theGraph) ? (NOTOK, 0) : 0) \ + : ((v) >= gp_UpperBoundVirtualVertices(theGraph) ? (NOTOK, 0) : 1))) + +#endif -// Reserve flag bits for possible future embedding-related extension modules -#define EMBEDFLAGS_SEARCHFORK5 (64 | EMBEDFLAGS_PLANAR) -#define EMBEDFLAGS_SEARCHFORK5MINOR (128 | EMBEDFLAGS_PLANAR) -#define EMBEDFLAGS_MAXIMALPLANARSUBGRAPH (256 | EMBEDFLAGS_PLANAR) -#define EMBEDFLAGS_PROJECTIVEPLANAR 512 -#define EMBEDFLAGS_TOROIDAL 1024 +#define gp_IsNotVertex(theGraph, v) (!(gp_IsVertex(theGraph, v))) +#define gp_IsNotVirtualVertex(theGraph, v) (!(gp_IsVirtualVertex(theGraph, v))) + +#define gp_VirtualVertexInUse(theGraph, virtualVertex) (gp_IsEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) +#define gp_VirtualVertexNotInUse(theGraph, virtualVertex) (gp_IsNotEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) +/////////////////////////////////////////// +// End of Vertex iteration-related methods +////////////////////////////////////////// + +// Accessors for non-virtual and virtual vertex index value +#define gp_GetIndex(theGraph, v) (theGraph->V[v].index) +#define gp_SetIndex(theGraph, v, theIndex) (theGraph->V[v].index = theIndex) + +// Initializer for non-virtual and virtual vertex flags +#define gp_InitFlags(theGraph, v) (theGraph->V[v].flags = 0) + +// Definition and accessors for the non-virtual and virtual vertex visited flag +#define VERTEX_VISITED_MASK 1 +#define gp_GetVisited(theGraph, v) (theGraph->V[v].flags & VERTEX_VISITED_MASK) +#define gp_ClearVisited(theGraph, v) (theGraph->V[v].flags &= ~VERTEX_VISITED_MASK) +#define gp_SetVisited(theGraph, v) (theGraph->V[v].flags |= VERTEX_VISITED_MASK) + +// Definition and accessors for the non-virtual and virtual vertex marked flag +// Essentially, this is a second visitation flag that can help applications that +// must visit all vertices to analyze and mark the ones important for some purpose. +#define VERTEX_MARKED_MASK 2 +#define gp_GetMarked(theGraph, v) (theGraph->V[v].flags & VERTEX_MARKED_MASK) +#define gp_ClearMarked(theGraph, v) (theGraph->V[v].flags &= ~VERTEX_MARKED_MASK) +#define gp_SetMarked(theGraph, v) (theGraph->V[v].flags |= VERTEX_MARKED_MASK) + + // DFS-RELATED and PLANARITY-RELATED ONLY + // Declaration of package-private data type for managing additional DFS- + // and planarity-related information associated with each non-virtual vertex + typedef struct DFSUtils_VertexInfo DFSUtils_VertexInfo; + typedef DFSUtils_VertexInfo *DFSUtils_VertexInfoP; + typedef struct Planarity_VertexInfo Planarity_VertexInfo; + typedef Planarity_VertexInfo *Planarity_VertexInfoP; + + // PLANARITY-RELATED ONLY + // Declaration of package private data type for optimizing management of + // the external face of a planar embedding as it is being built + typedef struct extFaceLinkRec extFaceLinkRec; + typedef extFaceLinkRec *extFaceLinkRecP; + + // DFS-RELATED and PLANARITY-RELATED ONLY + // Declaration of package-private data type for managing a + // stack of integers + typedef struct stackStruct stackStruct; + typedef stackStruct *stackP; + + // PLANARITY-RELATED ONLY + // Declaration of package private data type for isolating + // minimal subgraphs obstructing planarity-related embedding + typedef struct isolatorContextStruct isolatorContextStruct; + typedef isolatorContextStruct *isolatorContextP; + + // DFS-RELATED and PLANARITY-RELATED ONLY + // Declaration of package-private data type for managing a + // collection of lists of integers + typedef struct listCollectionStruct listCollectionStruct; + typedef listCollectionStruct *listCollectionP; + + // PLANARITY-RELATED ONLY + // Declaration of package private data types for extending the + // planarity algorithm to implement planarity-related algorithms + typedef struct graphExtensionStruct graphExtensionStruct; + typedef graphExtensionStruct *graphExtensionP; + + typedef struct graphFunctionTableStruct graphFunctionTableStruct; + typedef graphFunctionTableStruct *graphFunctionTableP; + + /******************************************************************** + Graph structure definition + V : Array of vertex records (allocated size N + NV) + N : Number of non-virtual vertices (the "order" of the graph) + NV: Number of virtual vertices (currently always equal to N) + + E : Array of edge records (edge records come in pairs and represent + an edge in each of the two vertex endpoints of the edge) + M: Number of edges (the "size" of the graph) + edgeCapacity: the maximum number of edges allowed in E + edgeHoles: free locations in E where edges have been deleted + numEdgeHoles: package private member indicating the number of edge holes. + + graphFlags: Additional state information about the graph + embedFlags: records the type of embedding requested (uses EMBEDFLAGS) + + theStack: Used by routines of various DFSUtils graph subclasses + BicompRootLists: storage for bicomp root lists (DFSUtils) or, for + Planarity, pertinent child bicomp lists that develop + during embedding + DVI: package private pointer; if the graph is extended to DFSUtils, + then N instances of DFSUtils vertex info records are allocated + + PVI: package private pointer; if the graph is extended to Planarity, + then N instances of Planarity vertex info records are allocated + IC: contains additional useful variables for Kuratowski subgraph isolation. + sortedDFSChildLists: for Planarity graphs, storage for the sorted DFS child + lists of each vertex + extFace: For Planarity graphs, an array of (N + NV) external face + short circuit records + + extensions: a list of extension data structures + functions: a table of function pointers that can be overloaded to provide + extension behaviors to the graph + + extraData: void pointer for extra package private data, if any. + This allows adding data members for graph subclasses + while maintaining backwards compatibility. + */ + + struct graphStruct + { + vertexRecP V; + int N, NV; + + edgeRecP E; + int M, edgeCapacity; + stackP edgeHoles; + int numEdgeHoles; + + unsigned graphFlags, embedFlags; + + stackP theStack; + listCollectionP BicompRootLists; + DFSUtils_VertexInfoP DVI; + + Planarity_VertexInfoP PVI; + listCollectionP sortedDFSChildLists; + extFaceLinkRecP extFace; + isolatorContextP IC; + + graphExtensionP extensions; + graphFunctionTableP functions; + + void *extraData; + }; + + typedef struct graphStruct graphStruct; + typedef graphStruct *graphP; #ifdef __cplusplus } diff --git a/planarity/c/graphLib/graph.private.h b/planarity/c/graphLib/graph.private.h new file mode 100644 index 0000000..946acce --- /dev/null +++ b/planarity/c/graphLib/graph.private.h @@ -0,0 +1,134 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHUTILS_PRIVATE_H +#define GRAPHUTILS_PRIVATE_H + +#include "extensionSystem/graphExtensions.h" +#include "extensionSystem/graphExtensions.private.h" + +#include "lowLevelUtils/listcoll.h" +#include "lowLevelUtils/stack.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/******************************************************************** + Additional edge link accessors and manipulators + ********************************************************************/ + +// Methods that enable getting the next or previous edge as if +// the adjacency list of the containing vertex were circular, +// i.e. that the first and last edge records were linked +#define gp_GetNextEdgeCircular(theGraph, e) \ + (gp_IsEdge(theGraph, gp_GetNextEdge(theGraph, e)) \ + ? gp_GetNextEdge(theGraph, e) \ + : gp_GetFirstEdge(theGraph, theGraph->E[gp_GetTwin(theGraph, e)].neighbor)) + +#define gp_GetPrevEdgeCircular(theGraph, e) \ + (gp_IsEdge(theGraph, gp_GetPrevEdge(theGraph, e)) \ + ? gp_GetPrevEdge(theGraph, e) \ + : gp_GetLastEdge(theGraph, theGraph->E[gp_GetTwin(theGraph, e)].neighbor)) + +// Methods that make the cross-link binding between a vertex and an +// edge record. The old first or last edge record should be bound to +// this new first or last edge record, e, by separate calls, +// e.g. see gp_AttachFirstEdge() and gp_AttachLastEdge() +#define gp_BindFirstEdge(theGraph, v, e) \ + { \ + gp_SetPrevEdge(theGraph, e, NIL); \ + gp_SetFirstEdge(theGraph, v, e); \ + } + +#define gp_BindLastEdge(theGraph, v, e) \ + { \ + gp_SetNextEdge(theGraph, e, NIL); \ + gp_SetLastEdge(theGraph, v, e); \ + } + +// Attaches edge e between the current binding between v and its first edge +#define gp_AttachFirstEdge(theGraph, v, e) \ + { \ + if (gp_IsEdge(theGraph, gp_GetFirstEdge(theGraph, v))) \ + { \ + gp_SetNextEdge(theGraph, e, gp_GetFirstEdge(theGraph, v)); \ + gp_SetPrevEdge(theGraph, gp_GetFirstEdge(theGraph, v), e); \ + } \ + else \ + gp_BindLastEdge(theGraph, v, e); \ + gp_BindFirstEdge(theGraph, v, e); \ + } + +// Attaches edge e between the current binding between v and its last edge +#define gp_AttachLastEdge(theGraph, v, e) \ + { \ + if (gp_IsEdge(theGraph, gp_GetLastEdge(theGraph, v))) \ + { \ + gp_SetPrevEdge(theGraph, e, gp_GetLastEdge(theGraph, v)); \ + gp_SetNextEdge(theGraph, gp_GetLastEdge(theGraph, v), e); \ + } \ + else \ + gp_BindFirstEdge(theGraph, v, e); \ + gp_BindLastEdge(theGraph, v, e); \ + } + +// Moves an edge e that is in the adjacency list of v to the start of the adjacency list +#define gp_MoveEdgeToFirst(theGraph, v, e) \ + if (e != gp_GetFirstEdge(theGraph, v)) \ + { \ + /* If e is last in the adjacency list of v, then we \ + detach it by adjacency list end management */ \ + if (e == gp_GetLastEdge(theGraph, v)) \ + { \ + gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), NIL); \ + gp_SetLastEdge(theGraph, v, gp_GetPrevEdge(theGraph, e)); \ + } \ + /* Otherwise, we detach e from the middle of the list */ \ + else \ + { \ + gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), gp_GetNextEdge(theGraph, e)); \ + gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), gp_GetPrevEdge(theGraph, e)); \ + } \ + \ + /* Now add e as the new first edge of v. \ + Note that the adjacency list is non-empty at this time */ \ + gp_SetNextEdge(theGraph, e, gp_GetFirstEdge(theGraph, v)); \ + gp_SetPrevEdge(theGraph, gp_GetFirstEdge(theGraph, v), e); \ + gp_BindFirstEdge(theGraph, v, e); \ + } + +// Moves an edge e that is in the adjacency list of v to the end of the adjacency list +#define gp_MoveEdgeToLast(theGraph, v, e) \ + if (e != gp_GetLastEdge(theGraph, v)) \ + { \ + /* If e is first in the adjacency list of vertex v, then we \ + detach it by adjacency list beginning management */ \ + if (e == gp_GetFirstEdge(theGraph, v)) \ + { \ + gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), NIL); \ + gp_SetFirstEdge(theGraph, v, gp_GetNextEdge(theGraph, e)); \ + } \ + /* Otherwise, we detach e from the middle of the list */ \ + else \ + { \ + gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), gp_GetNextEdge(theGraph, e)); \ + gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), gp_GetPrevEdge(theGraph, e)); \ + } \ + \ + /* Now we add e as the new last edge of v. \ + Note that the adjacency list is non-empty at this time */ \ + gp_SetPrevEdge(theGraph, e, gp_GetLastEdge(theGraph, v)); \ + gp_SetNextEdge(theGraph, gp_GetLastEdge(theGraph, v), e); \ + gp_BindLastEdge(theGraph, v, e); \ + } + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHUTILS_PRIVATE_H */ diff --git a/planarity/c/graphLib/graphDFSUtils.c b/planarity/c/graphLib/graphDFSUtils.c index e1d3b38..04acbc7 100644 --- a/planarity/c/graphLib/graphDFSUtils.c +++ b/planarity/c/graphLib/graphDFSUtils.c @@ -6,46 +6,108 @@ See the LICENSE.TXT file for licensing information. #define GRAPHDFSUTILS_C -#include "graph.h" +#include "graphDFSUtils.h" +#include "graphDFSUtils.private.h" + +// For LOGGING-related declarations +#include "lowLevelUtils/apiutils.private.h" + +// Allows the default _SortVertices() to swap planarity vertex info, if present +#include "planarityRelated/graphPlanarity.private.h" // Private methods, except exported within library int _SortVertices(graphP theGraph); // Imported methods -extern void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int); +extern void _ClearVertexVisitedFlags(graphP theGraph, int); + +/******************************************************************** + gp_ExtendWith_DFSUtils() + + Makes any necessary preparations for supporting DFS utility methods + that create a DFS tree, sort vertices, and compute least ancestor. + and lowpoint values. Those four utility methods automatically call + this method to extend the graph, though this method can also be + called beforehand. + + This method should be called after gp_InitGraph() or gp_Read() + because the number of vertices must be known. + + On success, sets GRAPHFLAGS_EXTENDEDWITH_DFSUTILS. + + Returns OK on success, NOTOK on failure. + ********************************************************************/ + +int gp_ExtendWith_DFSUtils(graphP theGraph) +{ + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + + // if the Graph has already been extended with DFS Utils, + // then just return successfully + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_DFSUTILS) + return OK; + + // Allocate supporting data structures as needed + + // Perform "on success" operations + theGraph->graphFlags |= GRAPHFLAGS_EXTENDEDWITH_DFSUTILS; + return OK; +} /******************************************************************** - gp_CreateDFSTree - Assigns Depth First Index (DFI) to each vertex. Also records parent - of each vertex in the DFS tree, and marks DFS tree edges that connect - parent and child. Forward edge records are also distinguished from - edges leading from a DFS tree descendant back to an ancestor. - The forward edge records are moved to the end of the adjacency list - to make the set easier to find and process. + gp_Detach_DFSUtils() + + This function is intended to disinherit the DFS Utils feature by + removing the extension from the graph, which also frees any + DFS-specific data structures. + + Clears GRAPHFLAGS_EXTENDEDWITH_DFSUTILS after detaching support for + the DFS utility methods. + + Returns OK for success, NOTOK for failure + ********************************************************************/ + +int gp_Detach_DFSUtils(graphP theGraph) +{ + // Free any data structures allocated by the ExtendWith function + + // Indicate successful detachment of DFSUtils + theGraph->graphFlags &= ~GRAPHFLAGS_EXTENDEDWITH_DFSUTILS; + return OK; +} + +/******************************************************************** + gp_DepthFirstSearch() + + This depth-first search (DFS) assigns a Depth First Index (DFI) to + each vertex and records the DFS parent of each vertex in each DFS tree + that forms during the depth-first search. Also, the type of each + edge record of each edge is set to indicate whether the edge record's + neighbor value points to a DFS child or parent (a DFS tree edge) or + a farther DFS ancestor or descendant (the backward and forward + edge records of a "back" edge/"cycle" edge/"co-tree" edge). NOTE: This is a utility function provided for general use. The core planarity algorithm uses its own DFS so it can build related - data structures at the same time as the DFS tree is created. + data structures at the same time. ********************************************************************/ -#include "lowLevelUtils/platformTime.h" - -int gp_CreateDFSTree(graphP theGraph) +int gp_DepthFirstSearch(graphP theGraph) { stackP theStack; int DFI, v, uparent, u, e; -#ifdef PROFILE - platform_time start, end; - platform_GetTime(start); -#endif - if (theGraph == NULL) return NOTOK; - if (gp_GetGraphFlags(theGraph) & FLAGS_DFSNUMBERED) + + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_DFSNUMBERED) return OK; - _gp_LogLine("\ngraphDFSUtils.c/gp_CreateDFSTree() start"); + if (gp_ExtendWith_DFSUtils(theGraph) != OK) + return NOTOK; + + _gp_LogLine("\ngraphDFSUtils.c/gp_DepthFirstSearch() start"); theStack = theGraph->theStack; @@ -63,12 +125,12 @@ int gp_CreateDFSTree(graphP theGraph) /* Clear the visited flags because they are used to detect what has been visited as the DFS traverses the graph. */ - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); /* This outer loop causes the connected subgraphs of a disconnected graph to be numbered */ - for (DFI = v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, DFI); v++) + for (DFI = v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (gp_IsNotDFSTreeRoot(theGraph, v)) continue; @@ -113,20 +175,16 @@ int gp_CreateDFSTree(graphP theGraph) } } - _gp_LogLine("graphDFSUtils.c/gp_CreateDFSTree() end\n"); + _gp_LogLine("graphDFSUtils.c/gp_DepthFirstSearch() end\n"); - theGraph->graphFlags |= FLAGS_DFSNUMBERED; - -#ifdef PROFILE - platform_GetTime(end); - printf("DFS in %.3lf seconds.\n", platform_GetDuration(start, end)); -#endif + theGraph->graphFlags |= GRAPHFLAGS_DFSNUMBERED; return OK; } /******************************************************************** gp_SortVertices() + Once depth first numbering has been applied to the graph, the index member of each vertex contains the DFI. This routine can reorder the vertices in linear time so that they appear in ascending order by DFI. @@ -146,7 +204,10 @@ int gp_SortVertices(graphP theGraph) if (theGraph == NULL) return NOTOK; - return theGraph->functions.fpSortVertices(theGraph); + if (gp_ExtendWith_DFSUtils(theGraph) != OK) + return NOTOK; + + return theGraph->functions->fpSortVertices(theGraph); } // Give macro names to swap operations used when sorting vertices @@ -156,34 +217,37 @@ int gp_SortVertices(graphP theGraph) // The index values of the first N vertices are changed to hold // the prior locations of vertices when they are rearranged to // or from DFI order. -#define _gp_SwapAnyTypeVertexRec(dstGraph, vdst, srcGraph, vsrc) \ - { \ - anyTypeVertexRec tempV = dstGraph->V[vdst]; \ - dstGraph->V[vdst] = srcGraph->V[vsrc]; \ - srcGraph->V[vsrc] = tempV; \ +#define _gp_SwapVertexRec(dstGraph, vdst, srcGraph, vsrc) \ + { \ + vertexRec tempV = dstGraph->V[vdst]; \ + dstGraph->V[vdst] = srcGraph->V[vsrc]; \ + srcGraph->V[vsrc] = tempV; \ + } +#define _gp_SwapDFSUtilsVertexInfo(dstGraph, dstPos, srcGraph, srcPos) \ + { \ + DFSUtils_VertexInfo tempDVI = dstGraph->DVI[dstPos]; \ + dstGraph->DVI[dstPos] = srcGraph->DVI[srcPos]; \ + srcGraph->DVI[srcPos] = tempDVI; \ } -#define _gp_SwapVertexInfo(dstGraph, dstPos, srcGraph, srcPos) \ - { \ - vertexInfo tempVI = dstGraph->VI[dstPos]; \ - dstGraph->VI[dstPos] = srcGraph->VI[srcPos]; \ - srcGraph->VI[srcPos] = tempVI; \ +#define _gp_SwapPlanarityVertexInfo(dstGraph, dstPos, srcGraph, srcPos) \ + if (dstGraph->PVI != NULL && srcGraph->PVI != NULL) \ + { \ + Planarity_VertexInfo tempPVI = dstGraph->PVI[dstPos]; \ + dstGraph->PVI[dstPos] = srcGraph->PVI[srcPos]; \ + srcGraph->PVI[srcPos] = tempPVI; \ } // This is the default method for sorting vertices into and back // out of DFI order. int _SortVertices(graphP theGraph) { - int v, EsizeOccupied, e, srcPos, dstPos; - -#ifdef PROFILE - platform_time start, end; - platform_GetTime(start); -#endif + int v, srcPos, dstPos; if (theGraph == NULL) return NOTOK; - if (!(gp_GetGraphFlags(theGraph) & FLAGS_DFSNUMBERED)) - if (gp_CreateDFSTree(theGraph) != OK) + + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_DFSNUMBERED)) + if (gp_DepthFirstSearch(theGraph) != OK) return NOTOK; _gp_LogLine("\ngraphDFSUtils.c/_SortVertices() start"); @@ -192,19 +256,30 @@ int _SortVertices(graphP theGraph) Also, if any links go back to locations 0 to n-1, then they need to be changed because we are reordering the vertices */ - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e += 2) + if (theGraph->numEdgeHoles == 0) { - if (gp_EdgeInUse(theGraph, e)) - { + // Slightly optimized loop body, for when edge deletion has not been used + // (Optimization level O1 or higher hoists the upperBoundEdges calculation, + // so this is mainly just a little less work in the loop body). + int upperBoundEdges = gp_LowerBoundEdges(theGraph) + (gp_GetM(theGraph) << 1); + for (int e = gp_LowerBoundEdges(theGraph); e < upperBoundEdges; ++e) gp_SetNeighbor(theGraph, e, gp_GetIndex(theGraph, gp_GetNeighbor(theGraph, e))); - gp_SetNeighbor(theGraph, e + 1, gp_GetIndex(theGraph, gp_GetNeighbor(theGraph, e + 1))); + } + else + { + for (int e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); e += 2) + { + if (gp_EdgeInUse(theGraph, e)) + { + gp_SetNeighbor(theGraph, e, gp_GetIndex(theGraph, gp_GetNeighbor(theGraph, e))); + gp_SetNeighbor(theGraph, e + 1, gp_GetIndex(theGraph, gp_GetNeighbor(theGraph, e + 1))); + } } } /* Convert DFSParent from v to DFI(v) or vice versa */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (gp_IsNotDFSTreeRoot(theGraph, v)) gp_SetVertexParent(theGraph, v, gp_GetIndex(theGraph, gp_GetVertexParent(theGraph, v))); @@ -216,7 +291,7 @@ int _SortVertices(graphP theGraph) location, so we cannot use index==v as a test for whether the correct vertex is in location 'index'. */ - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); /* We visit each vertex location, skipping those marked as visited since we've already moved the correct vertex into that location. The @@ -225,15 +300,16 @@ int _SortVertices(graphP theGraph) location as visited, then sets its index to be the location from whence we obtained the vertex record. */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { srcPos = v; while (!gp_GetVisited(theGraph, v)) { dstPos = gp_GetIndex(theGraph, v); - _gp_SwapAnyTypeVertexRec(theGraph, dstPos, theGraph, v); - _gp_SwapVertexInfo(theGraph, dstPos, theGraph, v); + _gp_SwapVertexRec(theGraph, dstPos, theGraph, v); + _gp_SwapDFSUtilsVertexInfo(theGraph, dstPos, theGraph, v); + _gp_SwapPlanarityVertexInfo(theGraph, dstPos, theGraph, v); gp_SetVisited(theGraph, dstPos); gp_SetIndex(theGraph, dstPos, srcPos); @@ -244,20 +320,16 @@ int _SortVertices(graphP theGraph) /* Invert the bit that records the sort order of the graph */ - theGraph->graphFlags ^= FLAGS_SORTEDBYDFI; + theGraph->graphFlags ^= GRAPHFLAGS_SORTEDBYDFI; _gp_LogLine("graphDFSUtils.c/_SortVertices() end\n"); -#ifdef PROFILE - platform_GetTime(end); - printf("SortVertices in %.3lf seconds.\n", platform_GetDuration(start, end)); -#endif - return OK; } /******************************************************************** gp_ComputeLowpoints() + leastAncestor(v): min(v, ancestor neighbors of v, excluding parent) Lowpoint(v): min(leastAncestor(v), Lowpoint of DFS children of v) @@ -274,7 +346,7 @@ int _SortVertices(graphP theGraph) values based on the childrens' lowpoints and the least ancestor from among the edges in the vertex's adjacency list. - If they have not already been performed, gp_CreateDFSTree() and + If they have not already been performed, gp_DepthFirstSearch() and gp_SortVertices() are invoked on the graph, and it is left in the sorted state on completion of this method. @@ -292,21 +364,19 @@ int gp_ComputeLowpoints(graphP theGraph) if (theGraph == NULL) return NOTOK; + if (gp_ExtendWith_DFSUtils(theGraph) != OK) + return NOTOK; + theStack = theGraph->theStack; - if (!(gp_GetGraphFlags(theGraph) & FLAGS_DFSNUMBERED)) - if (gp_CreateDFSTree(theGraph) != OK) + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_DFSNUMBERED)) + if (gp_DepthFirstSearch(theGraph) != OK) return NOTOK; - if (!(gp_GetGraphFlags(theGraph) & FLAGS_SORTEDBYDFI)) + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_SORTEDBYDFI)) if (gp_SortVertices(theGraph) != OK) return NOTOK; -#ifdef PROFILE - platform_time start, end; - platform_GetTime(start); -#endif - _gp_LogLine("\ngraphDFSUtils.c/gp_ComputeLowpoints() start"); // A stack of size N suffices because at maximum every vertex is pushed only once @@ -317,10 +387,10 @@ int gp_ComputeLowpoints(graphP theGraph) sp_ClearStack(theStack); - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); // This outer loop causes the connected subgraphs of a disconnected graph to be processed - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v);) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph);) { if (gp_GetVisited(theGraph, v)) { @@ -388,11 +458,6 @@ int gp_ComputeLowpoints(graphP theGraph) _gp_LogLine("graphDFSUtils.c/gp_ComputeLowpoints() end\n"); -#ifdef PROFILE - platform_GetTime(end); - printf("Lowpoint in %.3lf seconds.\n", platform_GetDuration(start, end)); -#endif - return OK; } @@ -402,7 +467,7 @@ int gp_ComputeLowpoints(graphP theGraph) By simple pre-order visitation, compute the least ancestor of each vertex that is directly adjacent to the vertex by a back edge. - If they have not already been performed, gp_CreateDFSTree() and + If they have not already been performed, gp_DepthFirstSearch() and gp_SortVertices() are invoked on the graph, and it is left in the sorted state on completion of this method. @@ -418,21 +483,19 @@ int gp_ComputeLeastAncestors(graphP theGraph) if (theGraph == NULL) return NOTOK; + if (gp_ExtendWith_DFSUtils(theGraph) != OK) + return NOTOK; + theStack = theGraph->theStack; - if (!(gp_GetGraphFlags(theGraph) & FLAGS_DFSNUMBERED)) - if (gp_CreateDFSTree(theGraph) != OK) + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_DFSNUMBERED)) + if (gp_DepthFirstSearch(theGraph) != OK) return NOTOK; - if (!(gp_GetGraphFlags(theGraph) & FLAGS_SORTEDBYDFI)) + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_SORTEDBYDFI)) if (gp_SortVertices(theGraph) != OK) return NOTOK; -#ifdef PROFILE - platform_time start, end; - platform_GetTime(start); -#endif - _gp_LogLine("\ngraphDFSUtils.c/gp_ComputeLeastAncestors() start"); // A stack of size N suffices because at maximum every vertex is pushed only once @@ -442,7 +505,7 @@ int gp_ComputeLeastAncestors(graphP theGraph) sp_ClearStack(theStack); // This outer loop causes the connected subgraphs of a disconnected graph to be processed - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v);) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph);) { if (gp_GetVisited(theGraph, v)) { @@ -484,10 +547,74 @@ int gp_ComputeLeastAncestors(graphP theGraph) _gp_LogLine("graphDFSUtils.c/gp_ComputeLeastAncestors() end\n"); -#ifdef PROFILE - platform_GetTime(end); - printf("LeastAncestor in %.3lf seconds.\n", platform_GetDuration(start, end)); + return OK; +} + +/******************************************************************** + gp_GetParent() + + Once the DFS tree has been created in theGraph, this method returns + the DFS parent of the given vertex v. This includes returning NIL + for a DFS tree root, which has no DFS parent. Also returns NIL on + error, such as invalid parameters or DFS tree not created yet. + ********************************************************************/ +int gp_GetParent(graphP theGraph, int v) +{ + if (theGraph == NULL || + v < gp_LowerBoundVertices(theGraph) || v >= gp_UpperBoundVertices(theGraph)) + { +#ifdef DEBUG + NOTOK; + ; #endif + return NIL; + } - return OK; + return gp_GetVertexParent(theGraph, v); +} + +/******************************************************************** + gp_GetLeastAncestor() + + Once the least ancestors have been computed in the graph, which + includes when they are implicitly calculated as part of computing + lowpoints, this method returns the least ancestor value for the + given vertex v. Returns NIL on error, such as invalid parameters + or least ancestor values not computed yet. + ********************************************************************/ +int gp_GetLeastAncestor(graphP theGraph, int v) +{ + if (theGraph == NULL || + v < gp_LowerBoundVertices(theGraph) || v >= gp_UpperBoundVertices(theGraph)) + { +#ifdef DEBUG + NOTOK; + ; +#endif + return NIL; + } + + return gp_GetVertexLeastAncestor(theGraph, v); +} + +/******************************************************************** + gp_GetLowpoint() + + Once the lowpoints have been computed in the graph, this method + returns the lowpoint value for the given vertex v. Returns NIL on + error, such as invalid parameters or lowpoints not computed yet. + ********************************************************************/ +int gp_GetLowpoint(graphP theGraph, int v) +{ + if (theGraph == NULL || + v < gp_LowerBoundVertices(theGraph) || v >= gp_UpperBoundVertices(theGraph)) + { +#ifdef DEBUG + NOTOK; + ; +#endif + return NIL; + } + + return gp_GetVertexLowpoint(theGraph, v); } diff --git a/planarity/c/graphLib/graphDFSUtils.h b/planarity/c/graphLib/graphDFSUtils.h new file mode 100644 index 0000000..71a3216 --- /dev/null +++ b/planarity/c/graphLib/graphDFSUtils.h @@ -0,0 +1,88 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHDFSUTILS_H +#define GRAPHDFSUTILS_H + +#include "graph.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +// Create a DFSUtils Graph, i.e., subclass a Graph by extending it with the +// ability to perform the depth-first search (DFS) utility methods below. +#define DFSUTILS_NAME "DFSUtils" + + int gp_ExtendWith_DFSUtils(graphP theGraph); + int gp_Detach_DFSUtils(graphP theGraph); + +/* Graph Flags: see gp_GetGraphFlags() + GRAPHFLAGS_EXTENDEDWITH_DFSUTILS is set by calling gp_ExtendWith_DFSUtils() + This is automatically called by the utility methods below that create + a DFS tree, sort vertices, and compute least ancestors and lowpoints + GRAPHFLAGS_DFSNUMBERED is set if DFS numbering has been performed on the graph, + such as by calling the gp_DepthFirstSearch() utility method below + GRAPHFLAGS_SORTEDBYDFI records whether the graph is in original vertex order + or sorted by depth first index. Successive calls to the + gp_SortVertices() utility method below toggle this bit. +*/ +#define GRAPHFLAGS_EXTENDEDWITH_DFSUTILS 256 +#define GRAPHFLAGS_DFSNUMBERED 512 +#define GRAPHFLAGS_SORTEDBYDFI 1024 + + // DFS-related utility methods that create a DFS tree, sort vertices and + // compute least ancestor and lowpoint values + int gp_DepthFirstSearch(graphP theGraph); + int gp_SortVertices(graphP theGraph); + int gp_ComputeLowpoints(graphP theGraph); + int gp_ComputeLeastAncestors(graphP theGraph); + + // Additional DFS-related uitility methods (functions and macros) that assume + // one or more of the above methods have been called to create a DFS tree, + // sort vertices and/or compute least ancestor and lowpoint values + int gp_GetParent(graphP theGraph, int v); + int gp_GetLeastAncestor(graphP theGraph, int v); + int gp_GetLowpoint(graphP theGraph, int v); + +// A DFS tree root is one that has no DFS parent. There is one DFS tree root +// per connected component of a graph (connected, not biconnected; component, not bicomp) +#define gp_IsDFSTreeRoot(theGraph, v) gp_IsNotVertex(theGraph, gp_GetVertexParent(theGraph, v)) +#define gp_IsNotDFSTreeRoot(theGraph, v) gp_IsVertex(theGraph, gp_GetVertexParent(theGraph, v)) + +// Mapping between bicomp roots and virtual vertex locations used to store them. +// A cut vertex v separates one or more of its DFS children, say c1 and c2, from +// the DFS parent and ancesstors of v. Because a DFS tree contains only tree edges +// and back edges, there are no cross edges connecting vertices in the DFS subtree +// rooted by c1, T(c1), with vertices in the DFS subtree rooted by c2, T(c2). +// We say that v is a cut vertex because the only paths that go from vertices in +// T(c1) to vertices in T(c2) are paths that contain v. +// +// Therefore, bicomp root copies of v, say R1 and R2, can be created at locations +// c1 and c2 in virtual vertex space, in other words at locations N+c1 and N+c2. +// The bicomps rooted by R1 and R2 are called child bicomps of v, and they contain, +// respectively, c1 and c2 as well as possibly more vertices from, respectively, +// T(c1) and T(c2), depending on what back edges may exist in the graph between +// pairs of vertices in, respectively, T(c1) and T(c2). +#define gp_GetBicompRootFromDFSChild(theGraph, c) ((c) + gp_GetN(theGraph)) +#define gp_GetDFSChildFromBicompRoot(theGraph, R) ((R) - gp_GetN(theGraph)) +#define gp_GetVertexFromBicompRoot(theGraph, R) gp_GetVertexParent(theGraph, gp_GetDFSChildFromBicompRoot(theGraph, R)) +#define gp_IsBicompRoot(theGraph, v) ((v) >= gp_LowerBoundVirtualVertices(theGraph)) + +// If a vertex v is a cut vertex that separates one of its DFS children, say c, +// from the DFS ancestors and other children of v, then when the graph has been +// separated into bicomps, there will be a root copy of v in virtual vertex space +// at location c+N that will have at least one edge connecting it to c. +// These macros detect whether or not that is the case for a given DFS child. +#define gp_IsSeparatedDFSChild(theGraph, theChild) (gp_VirtualVertexInUse(theGraph, gp_GetBicompRootFromDFSChild(theGraph, theChild))) +#define gp_IsNotSeparatedDFSChild(theGraph, theChild) (gp_VirtualVertexNotInUse(theGraph, gp_GetBicompRootFromDFSChild(theGraph, theChild))) + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHDFSUTILS_H */ diff --git a/planarity/c/graphLib/graphDFSUtils.private.h b/planarity/c/graphLib/graphDFSUtils.private.h new file mode 100644 index 0000000..c63c880 --- /dev/null +++ b/planarity/c/graphLib/graphDFSUtils.private.h @@ -0,0 +1,65 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHDFSUTILS_PRIVATE_H +#define GRAPHDFSUTILS_PRIVATE_H + +#include "graph.private.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /******************************************************************** + Vertex Info Structure Definition. + + This structure equips the non-virtual vertices with additional + information needed for DFS-related and planarity-related algorithms. + + parent: The DFI of the DFS tree parent of this vertex + leastAncestor: min(DFI of neighbors connected by backedge) + lowpoint: min(leastAncestor, min(lowpoint of DFS Children)) + */ + + struct DFSUtils_VertexInfo + { + int parent, leastAncestor, lowpoint; + }; + + typedef struct DFSUtils_VertexInfo DFSUtils_VertexInfo; + typedef DFSUtils_VertexInfo *DFSUtils_VertexInfoP; + + struct vertexInfoRec + { + int parent, leastAncestor, lowpoint; + + int visitedInfo; + + int pertinentEdge, + pertinentRoots, + futurePertinentChild, + sortedDFSChildList, + fwdEdgeList; + }; + + typedef struct vertexInfoRec vertexInfoRec; + typedef vertexInfoRec *vertexInfoP; + +#define gp_GetVertexParent(theGraph, v) (theGraph->DVI[v].parent) +#define gp_SetVertexParent(theGraph, v, theParent) (theGraph->DVI[v].parent = theParent) + +#define gp_GetVertexLeastAncestor(theGraph, v) (theGraph->DVI[v].leastAncestor) +#define gp_SetVertexLeastAncestor(theGraph, v, theLeastAncestor) (theGraph->DVI[v].leastAncestor = theLeastAncestor) + +#define gp_GetVertexLowpoint(theGraph, v) (theGraph->DVI[v].lowpoint) +#define gp_SetVertexLowpoint(theGraph, v, theLowpoint) (theGraph->DVI[v].lowpoint = theLowpoint) + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHPDFSUTILS_PRIVATE_H */ diff --git a/planarity/c/graphLib/graphLib.c b/planarity/c/graphLib/graphLib.c new file mode 100644 index 0000000..b5d8b9a --- /dev/null +++ b/planarity/c/graphLib/graphLib.c @@ -0,0 +1,40 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#include "graphLib.h" + +#include + +/******************************************************************** + gp_GetProjectVersionFull() + Return full major.minor.maint.tweak version string for the graph planarity project + ********************************************************************/ + +char *gp_GetProjectVersionFull(void) +{ + static char projectVersionStr[MAXLINE + 1]; + sprintf(projectVersionStr, "%d.%d.%d.%d", + GP_PROJECTVERSION_MAJOR, + GP_PROJECTVERSION_MINOR, + GP_PROJECTVERSION_MAINT, + GP_PROJECTVERSION_TWEAK); + return projectVersionStr; +} + +/******************************************************************** + gp_GetLibPlanarityVersionFull() + Returns full current:revision:age version string for the graph planarity shared library + ********************************************************************/ + +char *gp_GetLibPlanarityVersionFull(void) +{ + static char libPlanarityVersionStr[MAXLINE + 1]; + sprintf(libPlanarityVersionStr, "%d:%d:%d", + GP_LIBPLANARITYVERSION_CURRENT, + GP_LIBPLANARITYVERSION_REVISION, + GP_LIBPLANARITYVERSION_AGE); + return libPlanarityVersionStr; +} diff --git a/planarity/c/graphLib/graphLib.h b/planarity/c/graphLib/graphLib.h index 608ef3b..325b77f 100644 --- a/planarity/c/graphLib/graphLib.h +++ b/planarity/c/graphLib/graphLib.h @@ -14,17 +14,33 @@ extern "C" #include #include -#include #include +// Basic public API declarations, such as for OK, NOTOK, and NIL +#include "lowLevelUtils/appconst.h" +// And for get/set quiet mode, gp_ErrorMessage() and gp_Message() +#include "lowLevelUtils/apiutils.h" + +// Graph structure and public API methods #include "graph.h" -#include "lowLevelUtils/platformTime.h" +// Graph I/O public API methods and definitions +#include "io/graphIO.h" +#include "io/g6-read-iterator.h" +#include "io/g6-write-iterator.h" + +// Depth-first search public API methods and definitions +#include "graphDFSUtils.h" + +// Planarity-specific public API methods and definitions +#include "planarityRelated/graphPlanarity.h" +// Public APIs for extensions to the edge addition planarity algorithm +#include "planarityRelated/graphOuterplanarity.h" +#include "planarityRelated/graphDrawPlanar.h" #include "homeomorphSearch/graphK23Search.h" #include "homeomorphSearch/graphK33Search.h" #include "homeomorphSearch/graphK4Search.h" -#include "planarityRelated/graphDrawPlanar.h" // This is the main location for the project and shared library version numbering. // Changes here must be mirrored in configure.ac @@ -35,9 +51,9 @@ extern "C" // Maintenance is for functional revision (e.g. bug fix to existing algorithm implementation) // Tweak is for a non-functional revision (e.g. change of build scripts or testing code, user-facing string changes) -#define GP_PROJECTVERSION_MAJOR 4 +#define GP_PROJECTVERSION_MAJOR 5 #define GP_PROJECTVERSION_MINOR 0 -#define GP_PROJECTVERSION_MAINT 2 +#define GP_PROJECTVERSION_MAINT 0 #define GP_PROJECTVERSION_TWEAK 0 char *gp_GetProjectVersionFull(void); diff --git a/planarity/c/graphLib/graphStructures.h b/planarity/c/graphLib/graphStructures.h deleted file mode 100644 index c42b922..0000000 --- a/planarity/c/graphLib/graphStructures.h +++ /dev/null @@ -1,971 +0,0 @@ -#ifndef GRAPHSTRUCTURE_H -#define GRAPHSTRUCTURE_H - -/* -Copyright (c) 1997-2026, John M. Boyer -All rights reserved. -See the LICENSE.TXT file for licensing information. -*/ - -#include - -#include "lowLevelUtils/appconst.h" -#include "lowLevelUtils/listcoll.h" -#include "lowLevelUtils/stack.h" - -#include "extensionSystem/graphExtensions.private.h" -#include "extensionSystem/graphFunctionTable.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -// A return value to indicate success prior to completely processing a graph, whereas -// OK signifies EMBEDDABLE (no unreducible obstructions) and NOTOK signifies an exception. -#define NONEMBEDDABLE -1 - -// The initial setting for the edge storage capacity expressed as a constant factor of N, -// which is the number of vertices in the graph. By default, array E is allocated enough -// space to contain 3N edges, which is 6N edge records, but this initial setting -// can be overridden using gp_EnsureEdgeCapacity(). It is especially efficient to change -// to ensure a higher edge capacity if done before calling gp_InitGraph() or gp_Read(). -#define DEFAULT_EDGE_LIMIT 3 - - /******************************************************************** - Edge Record Definition - - An edge is defined by a pair of edge records allocated in array E - of a graph. A pair of edge records represents the edge in the - adjacency lists of each vertex to which the edge is incident. - - link[2]: the next and previous edge records in the adjacency - list that contains this edge record. - - v: The vertex neighbor of the vertex whose adjacency list contains - this edge record (an index into array V). - - flags: Bits 0-15 reserved for library; bits 16 and higher for apps - Bit 0: Visited - Bit 1: Marked (2nd visited flag, for while visiting all) - Bit 2: DFS type has been set, versus not set - Bit 3: DFS tree edge, versus cycle edge (co-tree edge, etc.) - Bit 4: DFS edge pointing to descendant, versus to ancestor - Bit 5: Inverted (same as marking an edge with a "sign" of -1) - Bit 6: Edge record is directed into the containing vertex only - Bit 7: Edge record is directed from the containing vertex only - ********************************************************************/ - - typedef struct - { - int link[2]; - int neighbor; - unsigned flags; - } edgeRec; - - typedef edgeRec *edgeRecP; - -#ifdef USE_FASTER_1BASEDARRAYS - -#ifndef DEBUG -#define gp_IsEdge(theGraph, e) (e) -#else -#define gp_IsEdge(theGraph, e) \ - ((e) == NIL \ - ? 0 \ - : ((e) < gp_EdgeArrayStart(theGraph) || (e) >= gp_EdgeArraySize(theGraph) \ - ? (NOTOK, 0) \ - : 1)) -#endif - -#define gp_IsNotEdge(theGraph, e) (!(e)) -#define gp_EdgeArrayStart(theGraph) (2) - -#else // When using slower 0-based Arrays - -#ifndef DEBUG -#define gp_IsEdge(theGraph, e) ((e) != NIL) -#else -#define gp_IsEdge(theGraph, e) \ - ((e) == NIL \ - ? 0 \ - : ((e) < gp_EdgeArrayStart(theGraph) || (e) >= gp_EdgeArraySize(theGraph) \ - ? (NOTOK, 0) \ - : 1)) -#endif - -#define gp_IsNotEdge(theGraph, e) ((e) == NIL) -#define gp_EdgeArrayStart(theGraph) (0) -#endif - -#define gp_EdgeInUse(theGraph, e) (gp_IsAnyTypeVertex(theGraph, gp_GetNeighbor(theGraph, e))) -#define gp_EdgeNotInUse(theGraph, e) (gp_IsNotAnyTypeVertex(theGraph, gp_GetNeighbor(theGraph, e))) -#define gp_EdgeArraySize(theGraph) (gp_EdgeArrayStart(theGraph) + ((theGraph)->edgeCapacity << 1)) -#define gp_EdgeInUseArraySize(theGraph) (gp_EdgeArrayStart(theGraph) + ((gp_GetM(theGraph) + sp_GetCurrentSize((theGraph)->edgeHoles)) << 1)) - -// An edge is represented by two consecutive edge records in the edge array E. -// If an even number, xor 1 will add one; if an odd number, xor 1 will subtract 1 -#define gp_GetTwin(theGraph, e) ((e) ^ 1) - -// Access to adjacency list pointers -#define gp_GetNextEdge(theGraph, e) (theGraph->E[e].link[0]) -#define gp_GetPrevEdge(theGraph, e) (theGraph->E[e].link[1]) -#define gp_GetAdjacentEdge(theGraph, e, theLink) (theGraph->E[e].link[theLink]) - -#define gp_SetNextEdge(theGraph, e, newNextEdge) (theGraph->E[e].link[0] = newNextEdge) -#define gp_SetPrevEdge(theGraph, e, newPrevEdge) (theGraph->E[e].link[1] = newPrevEdge) -#define gp_SetAdjacentEdge(theGraph, e, theLink, newEdge) (theGraph->E[e].link[theLink] = newEdge) - -// Get/set 'neighbor' member indicated by edge record e -#define gp_GetNeighbor(theGraph, e) (theGraph->E[e].neighbor) -#define gp_SetNeighbor(theGraph, e, v) (theGraph->E[e].neighbor = v) - -// Initializer for edge flags -#define gp_InitEdgeFlags(theGraph, e) (theGraph->E[e].flags = 0) - -// Definitions of and access to edge flags -#define EDGE_VISITED_MASK 1 -#define gp_GetEdgeVisited(theGraph, e) (theGraph->E[e].flags & EDGE_VISITED_MASK) -#define gp_ClearEdgeVisited(theGraph, e) (theGraph->E[e].flags &= ~EDGE_VISITED_MASK) -#define gp_SetEdgeVisited(theGraph, e) (theGraph->E[e].flags |= EDGE_VISITED_MASK) - -// Definition and accessors for the edge marked flag -// Essentially, this is a second visitation flag that can help applications that -// must visit all edges to analyze and mark the ones important for some purpose. -#define EDGE_MARKED_MASK 128 -#define gp_GetEdgeMarked(theGraph, e) (theGraph->E[e].flags & EDGE_MARKED_MASK) -#define gp_ClearEdgeMarked(theGraph, e) (theGraph->E[e].flags &= ~EDGE_MARKED_MASK) -#define gp_SetEdgeMarked(theGraph, e) (theGraph->E[e].flags |= EDGE_MARKED_MASK) - -// The edge type is defined by bits 2-4, 4+8+16=28 -#define EDGE_TYPE_MASK 28 - -// Call gp_GetEdgeType(), then compare to one of these four possibilities -// EDGE_TYPE_CHILD - edge record points to a neighboring DFS child -// EDGE_TYPE_FORWARD - edge record points to a DFS descendant, not a DFS child -// EDGE_TYPE_PARENT - edge record points to the DFS parent -// EDGE_TYPE_BACK - edge record points to a DFS ancestor, not the DFS parent -// NOTE: A parent/child tree edge has bit 3 (4) set, forward/back edges do not -#define EDGE_TYPE_CHILD 28 -#define EDGE_TYPE_FORWARD 20 -#define EDGE_TYPE_PARENT 12 -#define EDGE_TYPE_BACK 4 - -// EDGE_TYPE_NOTDEFINED - the edge record type has not been defined -// EDGE_TYPE_RANDOMTREE - edge record is part of a randomly generated tree -// NOTE: RANDOMTREE uses the same bit 3 as DFS tree edges above -#define EDGE_TYPE_NOTDEFINED 0 -#define EDGE_TYPE_RANDOMTREE 8 - -#define gp_GetEdgeType(theGraph, e) (theGraph->E[e].flags & EDGE_TYPE_MASK) -#define gp_ClearEdgeType(theGraph, e) (theGraph->E[e].flags &= ~EDGE_TYPE_MASK) -#define gp_SetEdgeType(theGraph, e, type) (theGraph->E[e].flags |= type) -#define gp_ResetEdgeType(theGraph, e, type) \ - (theGraph->E[e].flags = (theGraph->E[e].flags & ~EDGE_TYPE_MASK) | type) - -#define EDGEFLAG_INVERTED_MASK 32 -#define gp_GetEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags & EDGEFLAG_INVERTED_MASK) -#define gp_SetEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags |= EDGEFLAG_INVERTED_MASK) -#define gp_ClearEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags &= (~EDGEFLAG_INVERTED_MASK)) -#define gp_XorEdgeFlagInverted(theGraph, e) (theGraph->E[e].flags ^= EDGEFLAG_INVERTED_MASK) - -#define EDGEFLAG_DIRECTION_INONLY 64 -#define EDGEFLAG_DIRECTION_OUTONLY 128 -#define EDGEFLAG_DIRECTION_MASK 192 - -// Returns the direction, if any, of the edge record -#define gp_GetDirection(theGraph, e) (theGraph->E[e].flags & EDGEFLAG_DIRECTION_MASK) - -// A direction of 0 clears directedness. Otherwise, edge record e is set -// to direction and e's twin edge record is set to the opposing setting. -#define gp_SetDirection(theGraph, e, direction) \ - { \ - if (direction == EDGEFLAG_DIRECTION_INONLY) \ - { \ - theGraph->E[e].flags |= EDGEFLAG_DIRECTION_INONLY; \ - theGraph->E[gp_GetTwin(theGraph, e)].flags |= EDGEFLAG_DIRECTION_OUTONLY; \ - } \ - else if (direction == EDGEFLAG_DIRECTION_OUTONLY) \ - { \ - theGraph->E[e].flags |= EDGEFLAG_DIRECTION_OUTONLY; \ - theGraph->E[gp_GetTwin(theGraph, e)].flags |= EDGEFLAG_DIRECTION_INONLY; \ - } \ - else \ - { \ - theGraph->E[e].flags &= ~EDGEFLAG_DIRECTION_MASK; \ - theGraph->E[gp_GetTwin(theGraph, e)].flags &= ~EDGEFLAG_DIRECTION_MASK; \ - } \ - } - - /******************************************************************** - Vertex Record Definition (Any Type of Vertex) - - This record definition provides the data members needed for the - core structural information for both vertices and virtual vertices. - Vertices are also equipped with additional information provided by - the vertexInfo structure. - - The vertices of a graph are stored in the first N locations of array V. - Virtual vertices are secondary vertices used to help represent the - main vertices in substructural components of a graph (such as in - biconnected components). - - link[2]: the first and last edge records in the adjacency list - of the vertex. - - index: In vertices, stores either the depth first index of a vertex or - the original array index of the vertex if the vertices of the - graph are sorted by DFI. - In virtual vertices, the index may be used to indicate the vertex - that the virtual vertex represents, unless an algorithm has some - other way of making the association (for example, the planarity - algorithms rely on biconnected components and therefore place - virtual vertices of a vertex at positions corresponding to the - DFS children of the vertex). - - flags: Bits 0-15 reserved for library; bits 16 and higher for apps - Bit 0: visited, for vertices and virtual vertices - Bit 1: marked, 2nd visited flag, for while visiting all - Used in K4 homeomorph search algorithm - Bit 2: Obstruction type VERTEX_TYPE_SET (versus not set, i.e. VERTEX_TYPE_UNKNOWN) - Bit 3: Obstruction type qualifier RYW (set) versus RXW (clear) - Bit 4: Obstruction type qualifier high (set) versus low (clear) - Bits 2-4 used in planarity-related algorithms - ********************************************************************/ - - typedef struct - { - int link[2]; - int index; - unsigned flags; - } anyTypeVertexRec; - - typedef anyTypeVertexRec *anyTypeVertexRecP; - -//////////////////////////////////////////// -// Accessors for vertex adjacency list links -//////////////////////////////////////////// -#define gp_GetFirstEdge(theGraph, v) (theGraph->V[v].link[0]) -#define gp_GetLastEdge(theGraph, v) (theGraph->V[v].link[1]) -#define gp_GetEdgeByLink(theGraph, v, theLink) (theGraph->V[v].link[theLink]) - -#define gp_SetFirstEdge(theGraph, v, newFirstEdge) (theGraph->V[v].link[0] = newFirstEdge) -#define gp_SetLastEdge(theGraph, v, newLastEdge) (theGraph->V[v].link[1] = newLastEdge) -#define gp_SetEdgeByLink(theGraph, v, theLink, newEdge) (theGraph->V[v].link[theLink] = newEdge) - -/////////////////////////////////// -// Vertex iteration-related methods -/////////////////////////////////// -#ifdef USE_FASTER_1BASEDARRAYS - - // The use of *Vertex* alone consistently refers to the initial N vertices. - // The use of *VirtualVertex* refers to vertex array locations after the first N. - // The use of *AnyTypeVertex* refers to any non-virtual or virtual vertex - -#define gp_GetFirstVertex(theGraph) (1) -#define gp_GetLastVertex(theGraph) (gp_GetN(theGraph)) - -#define gp_GetFirstVirtualVertex(theGraph) (gp_GetN(theGraph) + 1) -#define gp_GetLastVirtualVertex(theGraph) (gp_GetN(theGraph) + gp_GetNV(theGraph)) - -#define gp_GetFirstAnyTypeVertex(theGraph) (gp_GetFirstVertex(theGraph)) -#define gp_GetLastAnyTypeVertex(theGraph) (gp_GetLastVirtualVertex(theGraph)) - -#ifndef DEBUG -#define gp_IsVertex(theGraph, v) (v) -#define gp_IsVirtualVertex(theGraph, v) ((v) > gp_GetN(theGraph)) -#define gp_IsAnyTypeVertex(theGraph, v) (v) -#else -#define gp_IsVertex(theGraph, v) \ - ((v) == NIL ? 0 : ((v) < gp_GetFirstVertex(theGraph) ? (NOTOK, 0) : ((v) > gp_GetLastVertex(theGraph) ? (NOTOK, 0) : 1))) - -// NOTE: gp_IsVirtualVertex() is sometimes called to distinguish between -// an existing non-virtual and a virtual -#define gp_IsVirtualVertex(theGraph, v) \ - ((v) == NIL \ - ? 0 \ - : ((v) < gp_GetFirstVirtualVertex(theGraph) \ - ? ((v) < gp_GetFirstVertex(theGraph) ? (NOTOK, 0) : 0) \ - : ((v) > gp_GetLastVirtualVertex(theGraph) ? (NOTOK, 0) : 1))) - -#define gp_IsAnyTypeVertex(theGraph, v) \ - ((v) == NIL \ - ? 0 \ - : ((v) < gp_GetFirstAnyTypeVertex(theGraph) \ - ? (NOTOK, 0) \ - : ((v) > gp_GetLastAnyTypeVertex(theGraph) ? (NOTOK, 0) : 1))) - -#endif - -#define gp_IsNotVertex(theGraph, v) (!(gp_IsVertex(theGraph, v))) -#define gp_IsNotVirtualVertex(theGraph, v) (!(gp_IsVirtualVertex(theGraph, v))) -#define gp_IsNotAnyTypeVertex(theGraph, v) (!(gp_IsAnyTypeVertex(theGraph, v))) - -#define gp_VertexInRangeAscending(theGraph, v) ((v) <= gp_GetN(theGraph)) -#define gp_VertexInRangeDescending(theGraph, v) (v) - -#define gp_VirtualVertexInRangeAscending(theGraph, v) ((v) <= gp_GetN(theGraph) + gp_GetNV(theGraph)) -#define gp_VirtualVertexInRangeDescending(theGraph, v) ((v) > gp_GetN(theGraph)) - -#define gp_AnyTypeVertexInRangeAscending(theGraph, v) (gp_VirtualVertexInRangeAscending(theGraph, v)) -#define gp_AnyTypeVertexInRangeDescending(theGraph, v) (gp_VirtualVertexInRangeDescending(theGraph, v)) - -#define gp_VertexArraySize(theGraph) (gp_GetFirstVertex(theGraph) + gp_GetN(theGraph)) -#define gp_AnyTypeVertexArraySize(theGraph) (gp_VertexArraySize(theGraph) + gp_GetNV(theGraph)) - -#define gp_VirtualVertexInUse(theGraph, virtualVertex) (gp_IsEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) -#define gp_VirtualVertexNotInUse(theGraph, virtualVertex) (gp_IsNotEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) - -#else // Using Slower 0-based Arrays - -#define gp_GetFirstVertex(theGraph) (0) -#define gp_GetLastVertex(theGraph) (gp_GetN(theGraph) - 1) - -#define gp_GetFirstVirtualVertex(theGraph) (gp_GetN(theGraph)) -#define gp_GetLastVirtualVertex(theGraph) (gp_GetN(theGraph) + gp_GetNV(theGraph) - 1) - -#define gp_GetFirstAnyTypeVertex(theGraph) (gp_GetFirstVertex(theGraph)) -#define gp_GetLastAnyTypeVertex(theGraph) (gp_GetLastVirtualVertex(theGraph)) - -#ifndef DEBUG -#define gp_IsVertex(theGraph, v) ((v) != NIL) -#define gp_IsVirtualVertex(theGraph, v) ((v) >= gp_GetN(theGraph)) -#define gp_IsAnyTypeVertex(theGraph, v) ((v) != NIL) -#else -#define gp_IsVertex(theGraph, v) \ - ((v) == NIL ? 0 : ((v) < gp_GetFirstVertex(theGraph) ? (NOTOK, 0) : ((v) > gp_GetLastVertex(theGraph) ? (NOTOK, 0) : 1))) - -#define gp_IsVirtualVertex(theGraph, v) \ - ((v) == NIL \ - ? 0 \ - : ((v) < gp_GetFirstVirtualVertex(theGraph) \ - ? ((v) < gp_GetFirstVertex(theGraph) ? (NOTOK, 0) : 0) \ - : ((v) > gp_GetLastVirtualVertex(theGraph) ? (NOTOK, 0) : 1))) - -#define gp_IsAnyTypeVertex(theGraph, v) \ - ((v) == NIL ? 0 : ((v) < gp_GetFirstAnyTypeVertex(theGraph) ? (NOTOK, 0) : ((v) > gp_GetLastAnyTypeVertex(theGraph) ? (NOTOK, 0) : 1))) -#endif - -#define gp_IsNotVertex(theGraph, v) (!(gp_IsVertex(theGraph, v))) -#define gp_IsNotVirtualVertex(theGraph, v) (!(gp_IsVirtualVertex(theGraph, v))) -#define gp_IsNotAnyTypeVertex(theGraph, v) (!(gp_IsAnyTypeVertex(theGraph, v))) - -#define gp_VertexInRangeAscending(theGraph, v) ((v) < gp_GetN(theGraph)) -#define gp_VertexInRangeDescending(theGraph, v) ((v) >= 0) - -#define gp_VirtualVertexInRangeAscending(theGraph, v) ((v) < gp_GetN(theGraph) + gp_GetNV(theGraph)) -#define gp_VirtualVertexInRangeDescending(theGraph, v) ((v) >= gp_GetN(theGraph)) - -#define gp_AnyTypeVertexInRangeAscending(theGraph, v) (gp_VirtualVertexInRangeAscending(theGraph, v)) -#define gp_AnyTypeVertexInRangeDescending(theGraph, v) (gp_VirtualVertexInRangeDescending(theGraph, v)) - -#define gp_VertexArraySize(theGraph) (gp_GetFirstVertex(theGraph) + gp_GetN(theGraph)) -#define gp_AnyTypeVertexArraySize(theGraph) (gp_VertexArraySize(theGraph) + gp_GetNV(theGraph)) - -#define gp_VirtualVertexInUse(theGraph, virtualVertex) (gp_IsEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) -#define gp_VirtualVertexNotInUse(theGraph, virtualVertex) (gp_IsNotEdge(theGraph, gp_GetFirstEdge(theGraph, virtualVertex))) - -#endif - /////////////////////////////////////////// - // End of Vertex iteration-related methods - ////////////////////////////////////////// - - // A DFS tree root is one that has no DFS parent. There is one DFS tree root -// per connected component of a graph (connected, not biconnected; component, not bicomp) -#define gp_IsDFSTreeRoot(theGraph, v) gp_IsNotVertex(theGraph, gp_GetVertexParent(theGraph, v)) -#define gp_IsNotDFSTreeRoot(theGraph, v) gp_IsVertex(theGraph, gp_GetVertexParent(theGraph, v)) - -// Accessors for "any type" vertex index -#define gp_GetIndex(theGraph, v) (theGraph->V[v].index) -#define gp_SetIndex(theGraph, v, theIndex) (theGraph->V[v].index = theIndex) - -// Initializer for "any type" vertex flags -#define gp_InitFlags(theGraph, v) (theGraph->V[v].flags = 0) - -// Definition and accessors for the "any type" vertex visited flag -#define ANYTYPEVERTEX_VISITED_MASK 1 -#define gp_GetVisited(theGraph, v) (theGraph->V[v].flags & ANYTYPEVERTEX_VISITED_MASK) -#define gp_ClearVisited(theGraph, v) (theGraph->V[v].flags &= ~ANYTYPEVERTEX_VISITED_MASK) -#define gp_SetVisited(theGraph, v) (theGraph->V[v].flags |= ANYTYPEVERTEX_VISITED_MASK) - -// Definition and accessors for the "any type" vertex marked flag -// Essentially, this is a second visitation flag that can help applications that -// must visit all vertices to analyze and mark the ones important for some purpose. -#define ANYTYPEVERTEX_MARKED_MASK 2 -#define gp_GetMarked(theGraph, v) (theGraph->V[v].flags & ANYTYPEVERTEX_MARKED_MASK) -#define gp_ClearMarked(theGraph, v) (theGraph->V[v].flags &= ~ANYTYPEVERTEX_MARKED_MASK) -#define gp_SetMarked(theGraph, v) (theGraph->V[v].flags |= ANYTYPEVERTEX_MARKED_MASK) - -// PLANARITY-RELATED ONLY -// -// The ANYVERTEX_OBSTRUCTIONMARK_MASK bits are bits 2-4, 4+8+16=28 -// They are used by planarity-related algorithms to identify the four -// regions of the external face cycle of a bicomp, relative to an -// XY-path in the bicomp. -// Bit 2 - 4 if the OBSTRUCTIONMARK is set, 0 if not -// Bit 3 - 8 if the OBSTRUCTIONMARK indicates Y side, 0 if X side -// Bit 4 - 16 if the OBSTRUCTIONMARK indicates high, 0 if low -#define ANYVERTEX_OBSTRUCTIONMARK_MASK 28 - -// Call gp_GetObstructionMark, then compare to one of these four possibilities -// ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW - On the external face path between vertices R and X -// ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW - X or on the external face path between vertices X and W -// ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW - On the external face path between vertices R and Y -// ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW - Y or on the external face path between vertices Y and W -// ANYVERTEX_OBSTRUCTIONMARK_UNMARKED - corresponds to all three bits off -#define ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW 20 -#define ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW 4 -#define ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW 28 -#define ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW 12 -#define ANYVERTEX_OBSTRUCTIONMARK_UNMARKED 0 - -#define gp_GetObstructionMark(theGraph, v) (theGraph->V[v].flags & ANYVERTEX_OBSTRUCTIONMARK_MASK) -#define gp_ClearObstructionMark(theGraph, v) (theGraph->V[v].flags &= ~ANYVERTEX_OBSTRUCTIONMARK_MASK) -#define gp_SetObstructionMark(theGraph, v, type) (theGraph->V[v].flags |= type) -#define gp_ResetObstructionMark(theGraph, v, type) \ - (theGraph->V[v].flags = (theGraph->V[v].flags & ~ANYVERTEX_OBSTRUCTIONMARK_MASK) | type) - -// PLANARITY-RELATED ONLY -// -// Mapping between bicomp roots and virtual vertex locations used to store them. -// A cut vertex v separates one or more of its DFS children, say c1 and c2, from -// the DFS parent and ancesstors of v. Because a DFS tree contains only tree edges -// and back edges, there are no cross edges connecting vertices in the DFS subtree -// rooted by c1, T(c1), with vertices in the DFS subtree rooted by c2, T(c2). -// We say that v is a cut vertex because the only paths that go from vertices in -// T(c1) to vertices in T(c2) are paths that contain v. -// Therefore, bicomp root copies of v, say R1 and R2, can be created at locations -// c1 and c2 in virtual vertex space, in other words at locations N+c1 and N+c2. -// The bicomps rooted by R1 and R2 are called child bicomps of v, and they contain, -// respectively, c1 and c2 as well as possibly more vertices from, respectively, -// T(c1) and T(c2), depending on what back edges may exist in the graph between -// pairs of vertices in, respectively, T(c1) and T(c2). -#define gp_GetBicompRootFromDFSChild(theGraph, c) ((c) + gp_GetN(theGraph)) -#define gp_GetDFSChildFromBicompRoot(theGraph, R) ((R) - gp_GetN(theGraph)) -#define gp_GetVertexFromBicompRoot(theGraph, R) gp_GetVertexParent(theGraph, gp_GetDFSChildFromBicompRoot(theGraph, R)) -#define gp_IsBicompRoot(theGraph, v) (!gp_VertexInRangeAscending(theGraph, v)) - -// PLANARITY-RELATED ONLY -// -// If a vertex v is a cut vertex that separates one of its DFS children, say c, -// from the DFS ancestors and other children of v, then when the graph has been -// separated into bicomps, there will be a root copy of v in virtual vertex space -// at location c+N that will have at least one edge connecting it to c. -// These macros detect whether or not that is the case for a given DFS child. -#define gp_IsSeparatedDFSChild(theGraph, theChild) (gp_VirtualVertexInUse(theGraph, gp_GetBicompRootFromDFSChild(theGraph, theChild))) -#define gp_IsNotSeparatedDFSChild(theGraph, theChild) (gp_VirtualVertexNotInUse(theGraph, gp_GetBicompRootFromDFSChild(theGraph, theChild))) - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - This structure defines a pair of links used by each vertex and virtual vertex - to create "short circuit" paths that eliminate unimportant vertices from - the external face, enabling more efficient traversal of the external face. - - It is also possible to embed the "short circuit" edges, but this approach - creates a better separation of concerns, imparts greater clarity, and - removes exceptionalities for handling additional fake "short circuit" edges. - - vertex[2]: The two adjacent vertices along the external face, possibly - short-circuiting paths of inactive vertices. - */ - - typedef struct - { - int vertex[2]; - } extFaceLinkRec; - - typedef extFaceLinkRec *extFaceLinkRecP; - -#define gp_GetExtFaceVertex(theGraph, v, link) (theGraph->extFace[v].vertex[link]) -#define gp_SetExtFaceVertex(theGraph, v, link, theVertex) (theGraph->extFace[v].vertex[link] = theVertex) - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - - Vertex Info Structure Definition. - - This structure equips the non-virtual vertices with additional - information needed for lowpoint and planarity-related algorithms. - - parent: The DFI of the DFS tree parent of this vertex - leastAncestor: min(DFI of neighbors connected by backedge) - lowpoint: min(leastAncestor, min(lowpoint of DFS Children)) - - visitedInfo: enables algorithms to manage vertex visitation with more than - just a flag. For example, the planarity test flags visitation - as a step number that implicitly resets on each step, whereas - part of the planar drawing method signifies a first visitation - by storing the index of the first edge used to reach a vertex - pertinentEdge: Used by the planarity method; during Walkup, each vertex - that is directly adjacent via a back edge to the vertex v - currently being embedded will have the forward edge's index - stored in this field. During Walkdown, each vertex for which - this field is set will cause a back edge to be embedded. - Implicitly resets at each vertex step of the planarity method - pertinentRootsList: used by Walkup to store a list of child bicomp roots of - a vertex descendant of the current vertex that are pertinent - and must be merged by the Walkdown in order to embed the cycle - edges of the current vertex. Future pertinent child bicomp roots - are placed at the end of the list to ensure bicomps that are - only pertinent are processed first. - futurePertinentChild: indicates a DFS child with a lowpoint less than the - current vertex v. This member is initialized to the start of - the sortedDFSChildList and is advanced in a relaxed manner as - needed until one with a lowpoint less than v is found or until - there are no more children. - sortedDFSChildList: at the start of embedding, the list of DFS children of - this vertex is calculated in ascending order by DFI (sorted in - linear time). The list is used during Walkdown processing of - a vertex to process all of its children. It is also used in - future pertinence management when processing the ancestors of - the vertex. When a child C is merged into the same bicomp as - the vertex, it is removed from the list. - fwdEdgeList: at the start of embedding, the "back" edges from a vertex to - its DFS *descendants* (i.e. the forward edge records) are - separated from the main adjacency list and placed in a - circular list until they are embedded. The list is sorted in - ascending DFI order of the descendants (in linear time). - This member indicates (by index) a node in that list. - */ - - typedef struct - { - int parent, leastAncestor, lowpoint; - - int visitedInfo; - - int pertinentEdge, - pertinentRoots, - futurePertinentChild, - sortedDFSChildList, - fwdEdgeList; - } vertexInfo; - - typedef vertexInfo *vertexInfoP; - -#define gp_GetVertexVisitedInfo(theGraph, v) (theGraph->VI[v].visitedInfo) -#define gp_SetVertexVisitedInfo(theGraph, v, theVisitedInfo) (theGraph->VI[v].visitedInfo = theVisitedInfo) - -#define gp_GetVertexParent(theGraph, v) (theGraph->VI[v].parent) -#define gp_SetVertexParent(theGraph, v, theParent) (theGraph->VI[v].parent = theParent) - -#define gp_GetVertexLeastAncestor(theGraph, v) (theGraph->VI[v].leastAncestor) -#define gp_SetVertexLeastAncestor(theGraph, v, theLeastAncestor) (theGraph->VI[v].leastAncestor = theLeastAncestor) - -#define gp_GetVertexLowpoint(theGraph, v) (theGraph->VI[v].lowpoint) -#define gp_SetVertexLowpoint(theGraph, v, theLowpoint) (theGraph->VI[v].lowpoint = theLowpoint) - -#define gp_GetVertexPertinentEdge(theGraph, v) (theGraph->VI[v].pertinentEdge) -#define gp_SetVertexPertinentEdge(theGraph, v, e) (theGraph->VI[v].pertinentEdge = e) - -#define gp_GetVertexPertinentRootsList(theGraph, v) (theGraph->VI[v].pertinentRoots) -#define gp_SetVertexPertinentRootsList(theGraph, v, pertinentRootsHead) (theGraph->VI[v].pertinentRoots = pertinentRootsHead) - -#define gp_GetVertexFirstPertinentRoot(theGraph, v) gp_GetBicompRootFromDFSChild(theGraph, theGraph->VI[v].pertinentRoots) -#define gp_GetVertexFirstPertinentRootChild(theGraph, v) (theGraph->VI[v].pertinentRoots) -#define gp_GetVertexLastPertinentRoot(theGraph, v) gp_GetBicompRootFromDFSChild(theGraph, LCGetPrev(theGraph->BicompRootLists, theGraph->VI[v].pertinentRoots, NIL)) -#define gp_GetVertexLastPertinentRootChild(theGraph, v) LCGetPrev(theGraph->BicompRootLists, theGraph->VI[v].pertinentRoots, NIL) - -#define gp_DeleteVertexPertinentRoot(theGraph, v, R) \ - gp_SetVertexPertinentRootsList(theGraph, v, \ - LCDelete(theGraph->BicompRootLists, \ - gp_GetVertexPertinentRootsList(theGraph, v), \ - gp_GetDFSChildFromBicompRoot(theGraph, R))) - -#define gp_PrependVertexPertinentRoot(theGraph, v, R) \ - gp_SetVertexPertinentRootsList(theGraph, v, \ - LCPrepend(theGraph->BicompRootLists, \ - gp_GetVertexPertinentRootsList(theGraph, v), \ - gp_GetDFSChildFromBicompRoot(theGraph, R))) - -#define gp_AppendVertexPertinentRoot(theGraph, v, R) \ - gp_SetVertexPertinentRootsList(theGraph, v, \ - LCAppend(theGraph->BicompRootLists, \ - gp_GetVertexPertinentRootsList(theGraph, v), \ - gp_GetDFSChildFromBicompRoot(theGraph, R))) - -#define gp_GetVertexFuturePertinentChild(theGraph, v) (theGraph->VI[v].futurePertinentChild) -#define gp_SetVertexFuturePertinentChild(theGraph, v, theFuturePertinentChild) (theGraph->VI[v].futurePertinentChild = theFuturePertinentChild) - -// Used to advance futurePertinentChild of w to the next separated DFS child with a lowpoint less than v -// Once futurePertinentChild advances past a child, no future planarity operation could make that child -// relevant to future pertinence. -#define gp_UpdateVertexFuturePertinentChild(theGraph, w, v) \ - while (gp_IsVertex(theGraph, theGraph->VI[w].futurePertinentChild)) \ - { \ - /* Skip children that 1) aren't future pertinent, 2) have been merged into the bicomp with w */ \ - if (gp_GetVertexLowpoint(theGraph, theGraph->VI[w].futurePertinentChild) >= v || \ - gp_IsNotSeparatedDFSChild(theGraph, theGraph->VI[w].futurePertinentChild)) \ - { \ - theGraph->VI[w].futurePertinentChild = \ - gp_GetVertexNextDFSChild(theGraph, w, gp_GetVertexFuturePertinentChild(theGraph, w)); \ - } \ - else \ - break; \ - } - -#define gp_GetVertexSortedDFSChildList(theGraph, v) (theGraph->VI[v].sortedDFSChildList) -#define gp_SetVertexSortedDFSChildList(theGraph, v, theSortedDFSChildList) (theGraph->VI[v].sortedDFSChildList = theSortedDFSChildList) - -#define gp_GetVertexNextDFSChild(theGraph, v, c) LCGetNext(theGraph->sortedDFSChildLists, gp_GetVertexSortedDFSChildList(theGraph, v), c) - -#define gp_AppendDFSChild(theGraph, v, c) \ - LCAppend(theGraph->sortedDFSChildLists, gp_GetVertexSortedDFSChildList(theGraph, v), c) - -#define gp_GetVertexFwdEdgeList(theGraph, v) (theGraph->VI[v].fwdEdgeList) -#define gp_SetVertexFwdEdgeList(theGraph, v, theFwdEdgeList) (theGraph->VI[v].fwdEdgeList = theFwdEdgeList) - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - Variables needed in embedding by Kuratowski subgraph isolator: - minorType: the type of planarity obstruction found. - v: the current vertex being processed - r: the root of the bicomp on which the Walkdown failed - x,y: stopping vertices on bicomp rooted by r - w: pertinent vertex on ext. face path below x and y - px, py: attachment points of x-y path, - z: Unused except in minors D and E (not needed in A, B, C). - - ux,dx: endpoints of unembedded edge that helps connext x with - ancestor of v - uy,dy: endpoints of unembedded edge that helps connext y with - ancestor of v - dw: descendant endpoint in unembedded edge to v - uz,dz: endpoints of unembedded edge that helps connext z with - ancestor of v (for minors B and E, not A, C, D). - */ - - typedef struct - { - int minorType; - int v, r, x, y, w, px, py, z; - int ux, dx, uy, dy, dw, uz, dz; - } isolatorContext; - - typedef isolatorContext *isolatorContextP; - -#define MINORTYPE_A 1 -#define MINORTYPE_B 2 -#define MINORTYPE_C 4 -#define MINORTYPE_D 8 -#define MINORTYPE_E 16 -#define MINORTYPE_E1 32 -#define MINORTYPE_E2 64 -#define MINORTYPE_E3 128 -#define MINORTYPE_E4 256 - -#define MINORTYPE_E5 512 -#define MINORTYPE_E6 1024 -#define MINORTYPE_E7 2048 - - /******************************************************************** - Graph structure definition - V : Array of vertex records (allocated size N + NV) - VI: Array of additional vertexInfo structures (allocated size N) - N : Number of non-virtual vertices (the "order" of the graph) - NV: Number of virtual vertices (currently always equal to N) - - E : Array of edge records (edge records come in pairs and represent - an edge in each of the two vertex endpoints of the edge) - M: Number of edges (the "size" of the graph) - edgeCapacity: the maximum number of edges allowed in E - edgeHoles: free locations in E where edges have been deleted - - theStack: Used by various graph routines needing a stack - graphFlags: Additional state information about the graph - embedFlags: records the type of embedding requested (uses EMBEDFLAGS) - - IC: contains additional useful variables for Kuratowski subgraph isolation. - BicompRootLists: storage space for pertinent bicomp root lists that develop - during embedding - sortedDFSChildLists: storage for the sorted DFS child lists of each vertex - extFace: Array of (N + NV) external face short circuit records - - extensions: a list of extension data structures - functions: a table of function pointers that can be overloaded to provide - extension behaviors to the graph - */ - - struct baseGraphStructure - { - anyTypeVertexRecP V; - vertexInfoP VI; - int N, NV; - - edgeRecP E; - int M, edgeCapacity; - stackP edgeHoles; - - stackP theStack; - int graphFlags, embedFlags; - - isolatorContext IC; - listCollectionP BicompRootLists, sortedDFSChildLists; - extFaceLinkRecP extFace; - - graphExtensionP extensions; - graphFunctionTable functions; - }; - - typedef struct baseGraphStructure baseGraphStructure; - typedef baseGraphStructure *graphP; - -// The current implementation extends the base graph with planarity and outerplanarity -// by default, but a future version may separate these into a "subclass" (extension). -#define gp_ExtendWith_Planarity(theGraph) (OK) -#define gp_ExtendWith_Outerplanarity(theGraph) (OK) - -// While the graph is extended with planarity and outerplanarity by default, -// the extensions are not removable. -#define gp_Detach_Planarity(theGraph) (NOTOK) -#define gp_Detach_Outerplanarity(theGraph) (NOTOK) - -/******************************************************************** - More link structure accessors/manipulators - ********************************************************************/ - -// Methods that enable getting the next or previous edge as if -// the adjacency list of the containing vertex were circular, -// i.e. that the first and last edge records were linked -#define gp_GetNextEdgeCircular(theGraph, e) \ - (gp_IsEdge(theGraph, gp_GetNextEdge(theGraph, e)) \ - ? gp_GetNextEdge(theGraph, e) \ - : gp_GetFirstEdge(theGraph, theGraph->E[gp_GetTwin(theGraph, e)].neighbor)) - -#define gp_GetPrevEdgeCircular(theGraph, e) \ - (gp_IsEdge(theGraph, gp_GetPrevEdge(theGraph, e)) \ - ? gp_GetPrevEdge(theGraph, e) \ - : gp_GetLastEdge(theGraph, theGraph->E[gp_GetTwin(theGraph, e)].neighbor)) - -// Methods that make the cross-link binding between a vertex and an -// edge record. The old first or last edge record should be bound to -// this new first or last edge record, e, by separate calls, -// e.g. see gp_AttachFirstEdge() and gp_AttachLastEdge() -#define gp_BindFirstEdge(theGraph, v, e) \ - { \ - gp_SetPrevEdge(theGraph, e, NIL); \ - gp_SetFirstEdge(theGraph, v, e); \ - } - -#define gp_BindLastEdge(theGraph, v, e) \ - { \ - gp_SetNextEdge(theGraph, e, NIL); \ - gp_SetLastEdge(theGraph, v, e); \ - } - -// Attaches edge e between the current binding between v and its first edge -#define gp_AttachFirstEdge(theGraph, v, e) \ - { \ - if (gp_IsEdge(theGraph, gp_GetFirstEdge(theGraph, v))) \ - { \ - gp_SetNextEdge(theGraph, e, gp_GetFirstEdge(theGraph, v)); \ - gp_SetPrevEdge(theGraph, gp_GetFirstEdge(theGraph, v), e); \ - } \ - else \ - gp_BindLastEdge(theGraph, v, e); \ - gp_BindFirstEdge(theGraph, v, e); \ - } - -// Attaches edge e between the current binding between v and its last edge -#define gp_AttachLastEdge(theGraph, v, e) \ - { \ - if (gp_IsEdge(theGraph, gp_GetLastEdge(theGraph, v))) \ - { \ - gp_SetPrevEdge(theGraph, e, gp_GetLastEdge(theGraph, v)); \ - gp_SetNextEdge(theGraph, gp_GetLastEdge(theGraph, v), e); \ - } \ - else \ - gp_BindFirstEdge(theGraph, v, e); \ - gp_BindLastEdge(theGraph, v, e); \ - } - -// Moves an edge e that is in the adjacency list of v to the start of the adjacency list -#define gp_MoveEdgeToFirst(theGraph, v, e) \ - if (e != gp_GetFirstEdge(theGraph, v)) \ - { \ - /* If e is last in the adjacency list of v, then we \ - detach it by adjacency list end management */ \ - if (e == gp_GetLastEdge(theGraph, v)) \ - { \ - gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), NIL); \ - gp_SetLastEdge(theGraph, v, gp_GetPrevEdge(theGraph, e)); \ - } \ - /* Otherwise, we detach e from the middle of the list */ \ - else \ - { \ - gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), gp_GetNextEdge(theGraph, e)); \ - gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), gp_GetPrevEdge(theGraph, e)); \ - } \ - \ - /* Now add e as the new first edge of v. \ - Note that the adjacency list is non-empty at this time */ \ - gp_SetNextEdge(theGraph, e, gp_GetFirstEdge(theGraph, v)); \ - gp_SetPrevEdge(theGraph, gp_GetFirstEdge(theGraph, v), e); \ - gp_BindFirstEdge(theGraph, v, e); \ - } - -// Moves an edge e that is in the adjacency list of v to the end of the adjacency list -#define gp_MoveEdgeToLast(theGraph, v, e) \ - if (e != gp_GetLastEdge(theGraph, v)) \ - { \ - /* If e is first in the adjacency list of vertex v, then we \ - detach it by adjacency list beginning management */ \ - if (e == gp_GetFirstEdge(theGraph, v)) \ - { \ - gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), NIL); \ - gp_SetFirstEdge(theGraph, v, gp_GetNextEdge(theGraph, e)); \ - } \ - /* Otherwise, we detach e from the middle of the list */ \ - else \ - { \ - gp_SetNextEdge(theGraph, gp_GetPrevEdge(theGraph, e), gp_GetNextEdge(theGraph, e)); \ - gp_SetPrevEdge(theGraph, gp_GetNextEdge(theGraph, e), gp_GetPrevEdge(theGraph, e)); \ - } \ - \ - /* Now we add e as the new last edge of v. \ - Note that the adjacency list is non-empty at this time */ \ - gp_SetPrevEdge(theGraph, e, gp_GetLastEdge(theGraph, v)); \ - gp_SetNextEdge(theGraph, gp_GetLastEdge(theGraph, v), e); \ - gp_BindLastEdge(theGraph, v, e); \ - } - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - PERTINENT() - A vertex is pertinent in a partially processed graph if there is an - unprocessed back edge between the vertex v whose edges are currently - being processed and either the vertex or a DFS descendant D of the - vertex not in the same bicomp as the vertex. - - The vertex is either directly adjacent to v by an unembedded back edge - or there is an unembedded back edge (v, D) and the vertex is a cut - vertex in the partially processed graph along the DFS tree path from - D to v. - - Pertinence is a dynamic property that can change for a vertex after - each edge addition. In other words, a vertex can become non-pertinent - during step v as more back edges to v are embedded. - - NOTE: Pertinent roots are stored using the DFS children with which - they are associated, so we test 'is vertex' (rather than virtual). - ********************************************************************/ - -#define PERTINENT(theGraph, theVertex) \ - (gp_IsEdge(theGraph, gp_GetVertexPertinentEdge(theGraph, theVertex)) || \ - gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theVertex))) - -#define NOTPERTINENT(theGraph, theVertex) \ - (gp_IsNotEdge(theGraph, gp_GetVertexPertinentEdge(theGraph, theVertex)) && \ - gp_IsNotVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theVertex))) - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - FUTUREPERTINENT() - A vertex is future-pertinent in a partially processed graph if - there is an unprocessed back edge between a DFS ancestor A of the - vertex v whose edges are currently being processed and either - theVertex or a DFS descendant D of theVertex not in the same bicomp - as theVertex. - - Either theVertex is directly adjacent to A by an unembedded back edge - or there is an unembedded back edge (A, D) and theVertex is a cut - vertex in the partially processed graph along the DFS tree path from - D to A. - - If no more edges are added to the partially processed graph prior to - processing the edges of A, then the vertex would be pertinent. - The addition of edges to the partially processed graph can alter - both the pertinence and future pertinence of a vertex. For example, - if the vertex is pertinent due to an unprocessed back edge (v, D1) and - future pertinent due to an unprocessed back edge (A, D2), then the - vertex may lose both its pertinence and future pertinence when edge - (v, D1) is added if D2 is in the same subtree as D1. - - Generally, pertinence and future pertinence are dynamic properties - that can change for a vertex after each edge addition. - - Note that gp_UpdateVertexFuturePertinentChild() must be called before - this macro. Since it is a statement and not a void expression, the - desired commented out version does not compile (except with special - compiler extensions not assumed by this code). - ********************************************************************/ - -#define FUTUREPERTINENT(theGraph, theVertex, v) \ - (theGraph->VI[theVertex].leastAncestor < v || \ - (gp_IsVertex(theGraph, theGraph->VI[theVertex].futurePertinentChild) && \ - theGraph->VI[theGraph->VI[theVertex].futurePertinentChild].lowpoint < v)) - -#define NOTFUTUREPERTINENT(theGraph, theVertex, v) \ - (theGraph->VI[theVertex].leastAncestor >= v && \ - (gp_IsNotVertex(theGraph, theGraph->VI[theVertex].futurePertinentChild) || \ - theGraph->VI[theGraph->VI[theVertex].futurePertinentChild].lowpoint >= v)) - - // This is the definition that would be preferable if a while loop could be a void expression - // #define FUTUREPERTINENT(theGraph, theVertex, v) - // ( theGraph->VI[theVertex].leastAncestor < v || - // ((gp_UpdateVertexFuturePertinentChild(theGraph, theVertex, v), - // gp_IsEdge(theGraph, theGraph->VI[theVertex].futurePertinentChild)) && - // theGraph->VI[theGraph->VI[theVertex].futurePertinentChild].lowpoint < v) ) - - /******************************************************************** - // PLANARITY-RELATED ONLY - // - INACTIVE() - For planarity algorithms, a vertex is inactive if it is neither pertinent - nor future pertinent. - ********************************************************************/ - -#define INACTIVE(theGraph, theVertex, v) \ - (NOTPERTINENT(theGraph, theVertex) && \ - NOTFUTUREPERTINENT(theGraph, theVertex, v)) - -/* PRIVATE FUNCTIONS FOR ADDITIONAL INFORMATIONAL LOGGING. - - If LOGGING is defined by uncommenting it below, then log-related lines - write to the log, and otherwise they no-op. - - By default, neither release nor DEBUG builds including LOGGING. - Logging is used to see more details of how various algorithms - handle a particular graph. */ - -// #define LOGGING -#ifdef LOGGING - -#define _gp_LogLine _LogLine -#define _gp_Log _Log - - void _LogLine(const char *Line); - void _Log(const char *Line); - -#define _gp_MakeLogStr1 _MakeLogStr1 -#define _gp_MakeLogStr2 _MakeLogStr2 -#define _gp_MakeLogStr3 _MakeLogStr3 -#define _gp_MakeLogStr4 _MakeLogStr4 -#define _gp_MakeLogStr5 _MakeLogStr5 - - char *_MakeLogStr1(char *format, int); - char *_MakeLogStr2(char *format, int, int); - char *_MakeLogStr3(char *format, int, int, int); - char *_MakeLogStr4(char *format, int, int, int, int); - char *_MakeLogStr5(char *format, int, int, int, int, int); - -#else -#define _gp_LogLine(Line) -#define _gp_Log(Line) -#define _gp_MakeLogStr1(format, one) -#define _gp_MakeLogStr2(format, one, two) -#define _gp_MakeLogStr3(format, one, two, three) -#define _gp_MakeLogStr4(format, one, two, three, four) -#define _gp_MakeLogStr5(format, one, two, three, four, five) -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/planarity/c/graphLib/homeomorphSearch/graphK23Search.c b/planarity/c/graphLib/homeomorphSearch/graphK23Search.c index c4bda81..f9ddd28 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK23Search.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK23Search.c @@ -4,7 +4,8 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "graphK23Search.h" +#include "graphK23Search.private.h" /* Imported functions */ @@ -42,7 +43,7 @@ int _IsolateOuterplanarityObstructionE3orE4(graphP theGraph); int _SearchForK23InBicomp(graphP theGraph, int v, int R) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int X, Y, XPrevLink, YPrevLink; /* Begin by determining whether minor A, B or E is detected */ @@ -53,11 +54,11 @@ int _SearchForK23InBicomp(graphP theGraph, int v, int R) /* Minors A and B result in the desired K_{2,3} homeomorph, so we isolate it and return NONEMBEDDABLE. */ - if (theGraph->IC.minorType & (MINORTYPE_A | MINORTYPE_B)) + if (theGraph->IC->minorType & (MINORTYPE_A | MINORTYPE_B)) { _ClearAllVisitedFlagsInGraph(theGraph); - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) { if (_FindUnembeddedEdgeToCurVertex(theGraph, IC->w, &IC->dw) != TRUE) return NOTOK; @@ -65,7 +66,7 @@ int _SearchForK23InBicomp(graphP theGraph, int v, int R) if (_IsolateOuterplanarityObstructionA(theGraph) != OK) return NOTOK; } - else if (theGraph->IC.minorType & MINORTYPE_B) + else if (theGraph->IC->minorType & MINORTYPE_B) { int SubtreeRoot = gp_GetVertexLastPertinentRootChild(theGraph, IC->w); @@ -151,21 +152,21 @@ int _SearchForK23InBicomp(graphP theGraph, int v, int R) int _IsolateOuterplanarityObstructionE1orE2(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int XPrevLink = 1; - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; /* Isolate E1 */ - if (theGraph->IC.px != theGraph->IC.x) + if (theGraph->IC->px != theGraph->IC->x) { if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->w) != OK || _MarkPathAlongBicompExtFace(theGraph, IC->py, IC->r) != OK) return NOTOK; } - else if (theGraph->IC.py != theGraph->IC.y) + else if (theGraph->IC->py != theGraph->IC->y) { if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->x) != OK || _MarkPathAlongBicompExtFace(theGraph, IC->w, IC->r) != OK) @@ -189,7 +190,7 @@ int _IsolateOuterplanarityObstructionE1orE2(graphP theGraph) /* Final bits are in common */ if (_FindUnembeddedEdgeToCurVertex(theGraph, IC->w, &IC->dw) != TRUE || - theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkEdge(theGraph, IC->v, IC->dw) != OK) return NOTOK; @@ -203,29 +204,29 @@ int _IsolateOuterplanarityObstructionE1orE2(graphP theGraph) int _IsolateOuterplanarityObstructionE3orE4(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int u, d, XorY; // Minor E3 - gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC.x, theGraph->IC.v); - gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC.y, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, theGraph->IC.x, theGraph->IC.v) || - FUTUREPERTINENT(theGraph, theGraph->IC.y, theGraph->IC.v)) + gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC->x, theGraph->IC->v); + gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC->y, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, theGraph->IC->x, theGraph->IC->v) || + FUTUREPERTINENT(theGraph, theGraph->IC->y, theGraph->IC->v)) { - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; - gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC.x, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, theGraph->IC.x, theGraph->IC.v)) - XorY = theGraph->IC.x; + gp_UpdateVertexFuturePertinentChild(theGraph, theGraph->IC->x, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, theGraph->IC->x, theGraph->IC->v)) + XorY = theGraph->IC->x; else - XorY = theGraph->IC.y; + XorY = theGraph->IC->y; /* The cases of X future pertinent and Y future pertinent are the same except for the bicomp external face marking (because parameter order is important) */ - if (XorY == theGraph->IC.x) + if (XorY == theGraph->IC->x) { if (_MarkPathAlongBicompExtFace(theGraph, IC->x, IC->w) != OK || _MarkPathAlongBicompExtFace(theGraph, IC->y, IC->r) != OK) @@ -244,9 +245,9 @@ int _IsolateOuterplanarityObstructionE3orE4(graphP theGraph) if (_FindUnembeddedEdgeToAncestor(theGraph, XorY, &u, &d) != TRUE) return NOTOK; - if (theGraph->functions.fpMarkDFSPath(theGraph, u, IC->v) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, XorY, d) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || + if (theGraph->functions->fpMarkDFSPath(theGraph, u, IC->v) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, XorY, d) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkEdge(theGraph, u, d) != OK || _AddAndMarkEdge(theGraph, IC->v, IC->dw) != OK) diff --git a/planarity/c/graphLib/homeomorphSearch/graphK23Search.h b/planarity/c/graphLib/homeomorphSearch/graphK23Search.h index 0f32744..1763188 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK23Search.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK23Search.h @@ -7,13 +7,15 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graphStructures.h" +#include "../planarityRelated/graphOuterplanarity.h" #ifdef __cplusplus extern "C" { #endif +// Create a K23Search Graph, i.e., subclass an Outerplanarity Graph by extending it +// with the ability to perform a search for a subgraph homeomorphic to K_{2,3}. #define K23SEARCH_NAME "K23Search" int gp_ExtendWith_K23Search(graphP theGraph); diff --git a/planarity/c/graphLib/homeomorphSearch/graphK23Search.private.h b/planarity/c/graphLib/homeomorphSearch/graphK23Search.private.h index c79a9b8..bd02ce7 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK23Search.private.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK23Search.private.h @@ -7,7 +7,7 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "../planarityRelated/graphOuterplanarity.private.h" #ifdef __cplusplus extern "C" @@ -17,11 +17,11 @@ extern "C" typedef struct { // Overloaded function pointers - graphFunctionTable functions; + graphFunctionTableStruct functions; } K23SearchContext; -extern int K23SEARCH_ID; + extern int K23SEARCH_ID; #ifdef __cplusplus } diff --git a/planarity/c/graphLib/homeomorphSearch/graphK23Search_Extensions.c b/planarity/c/graphLib/homeomorphSearch/graphK23Search_Extensions.c index d1aae6c..5cfc391 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK23Search_Extensions.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK23Search_Extensions.c @@ -6,8 +6,11 @@ See the LICENSE.TXT file for licensing information. #include -#include "graphK23Search.private.h" #include "graphK23Search.h" +#include "graphK23Search.private.h" + +// Need to save and restore a graph flag related to IO +#include "../io/graphIO.h" extern int _SearchForK23InBicomp(graphP theGraph, int v, int R); @@ -47,6 +50,9 @@ int gp_ExtendWith_K23Search(graphP theGraph) { K23SearchContext *context = NULL; + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + // If the K2,3 search feature has already been attached to the graph // then there is no need to attach it again gp_FindExtension(theGraph, K23SEARCH_ID, (void *)&context); @@ -55,6 +61,10 @@ int gp_ExtendWith_K23Search(graphP theGraph) return OK; } + // Ensure theGraph is an Outerplanarity Graph + if (gp_ExtendWith_Outerplanarity(theGraph) != OK) + return NOTOK; + // Allocate a new extension context context = (K23SearchContext *)malloc(sizeof(K23SearchContext)); if (context == NULL) @@ -65,7 +75,7 @@ int gp_ExtendWith_K23Search(graphP theGraph) // Put the overload functions into the context function table. // gp_AddExtension will overload the graph's functions with these, and // return the base function pointers in the context function table - memset(&context->functions, 0, sizeof(graphFunctionTable)); + memset(&context->functions, 0, sizeof(graphFunctionTableStruct)); context->functions.fpHandleBlockedBicomp = _K23Search_HandleBlockedBicomp; context->functions.fpEmbedPostprocess = _K23Search_EmbedPostprocess; @@ -174,8 +184,8 @@ int _K23Search_EmbedPostprocess(graphP theGraph, int v, int edgeEmbeddingResult) // is meaningless, so we empty it out. We preserve the embedFlags // to ensure post-processing continues as expected. savedEmbedFlags = gp_GetEmbedFlags(theGraph); - savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & FLAGS_ZEROBASEDIO; - gp_ReinitializeGraph(theGraph); + savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & GRAPHFLAGS_ZEROBASEDIO; + gp_ReinitGraph(theGraph); theGraph->embedFlags = savedEmbedFlags; theGraph->graphFlags &= savedZEROBASEDIO; } diff --git a/planarity/c/graphLib/homeomorphSearch/graphK33Search.c b/planarity/c/graphLib/homeomorphSearch/graphK33Search.c index f215d15..40a3652 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK33Search.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK33Search.c @@ -7,8 +7,6 @@ See the LICENSE.TXT file for licensing information. #include "graphK33Search.h" #include "graphK33Search.private.h" -#include "../graph.h" - /* Imported functions */ // extern void _ClearAllVisitedFlagsInGraph(graphP); @@ -98,7 +96,7 @@ int _IsolateMinorE7(graphP theGraph, K33SearchContext *context); int _SearchForK33InBicomp(graphP theGraph, K33SearchContext *context, int v, int R) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int tempResult; /* Begin by determining which non-planarity minor is detected */ @@ -114,7 +112,7 @@ int _SearchForK33InBicomp(graphP theGraph, K33SearchContext *context, int v, int /* Minors A to D result in the desired K_{3,3} homeomorph, so we isolate it and return NONEMBEDDABLE. */ - if (theGraph->IC.minorType & (MINORTYPE_A | MINORTYPE_B | MINORTYPE_C | MINORTYPE_D)) + if (theGraph->IC->minorType & (MINORTYPE_A | MINORTYPE_B | MINORTYPE_C | MINORTYPE_D)) { /* First we restore the orientations of the vertices in the one bicomp we have messed with so that there is no confusion. */ @@ -136,7 +134,7 @@ int _SearchForK33InBicomp(graphP theGraph, K33SearchContext *context, int v, int For minor A, we need to set up the stack that would be available immediately after a Walkdown failure. */ - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) { sp_ClearStack(theGraph->theStack); sp_Push2(theGraph->theStack, R, NIL); @@ -236,7 +234,7 @@ int _SearchForK33InBicomp(graphP theGraph, K33SearchContext *context, int v, int int _RunExtraK33Tests(graphP theGraph, K33SearchContext *context) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int u_max = MAX3(IC->ux, IC->uy, IC->uz); #ifndef USE_MERGEBLOCKER @@ -455,27 +453,27 @@ int _RunExtraK33Tests(graphP theGraph, K33SearchContext *context) int _SearchForMinorE1(graphP theGraph) { - int Z = theGraph->IC.px, ZPrevLink = 1; + int Z = theGraph->IC->px, ZPrevLink = 1; Z = _GetNeighborOnExtFace(theGraph, Z, &ZPrevLink); - while (Z != theGraph->IC.py) + while (Z != theGraph->IC->py) { - if (Z != theGraph->IC.w) + if (Z != theGraph->IC->w) { - gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, Z, theGraph->IC.v)) + gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, Z, theGraph->IC->v)) { - theGraph->IC.z = Z; - theGraph->IC.uz = _GetLeastAncestorConnection(theGraph, Z); + theGraph->IC->z = Z; + theGraph->IC->uz = _GetLeastAncestorConnection(theGraph, Z); return OK; } else if (PERTINENT(theGraph, Z)) { /* Swap the roles of W and Z */ - theGraph->IC.z = theGraph->IC.w; - theGraph->IC.w = Z; + theGraph->IC->z = theGraph->IC->w; + theGraph->IC->w = Z; /* If the new W (indicated by Z) was on the path (R, X, old W) then the new Z (the old W, which has no type mark) is on the path @@ -484,17 +482,17 @@ int _SearchForMinorE1(graphP theGraph) new Z (old W with no type) is type changed to be on the RXW path.*/ if (gp_GetObstructionMark(theGraph, Z) == ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW) - gp_ResetObstructionMark(theGraph, theGraph->IC.z, ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW); + gp_ResetObstructionMark(theGraph, theGraph->IC->z, ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW); else - gp_ResetObstructionMark(theGraph, theGraph->IC.z, ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW); + gp_ResetObstructionMark(theGraph, theGraph->IC->z, ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW); /* For completeness, we change the new W to type unknown */ - gp_ClearObstructionMark(theGraph, theGraph->IC.w); + gp_ClearObstructionMark(theGraph, theGraph->IC->w); /* The external activity ancestor connection of the new Z must be obtained */ - theGraph->IC.uz = _GetLeastAncestorConnection(theGraph, theGraph->IC.z); + theGraph->IC->uz = _GetLeastAncestorConnection(theGraph, theGraph->IC->z); return OK; } @@ -514,7 +512,7 @@ int _SearchForMinorE1(graphP theGraph) int _FinishIsolatorContextInitialization(graphP theGraph, K33SearchContext *context) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; /* Restore the orientation of the bicomp on which we're working, then perform orientation of all vertices in graph. (An unnecessary but @@ -623,7 +621,7 @@ int _GetAdjacentAncestorInRange(graphP theGraph, K33SearchContext *context, int int _SearchForDescendantExternalConnection(graphP theGraph, K33SearchContext *context, int cutVertex, int u_max) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int u2 = _GetAdjacentAncestorInRange(theGraph, context, cutVertex, IC->v, u_max); int child, descendant; @@ -723,7 +721,7 @@ int _FindExternalConnectionDescendantEndpoint(graphP theGraph, int ancestor, child = gp_GetVertexSortedDFSChildList(theGraph, cutVertex); while (gp_IsVertex(theGraph, child)) { - if (gp_GetVertexLowpoint(theGraph, child) < theGraph->IC.v && gp_IsSeparatedDFSChild(theGraph, child)) + if (gp_GetVertexLowpoint(theGraph, child) < theGraph->IC->v && gp_IsSeparatedDFSChild(theGraph, child)) { if (_FindUnembeddedEdgeToSubtree(theGraph, ancestor, child, pDescendant) == TRUE) return OK; @@ -800,7 +798,7 @@ int _SearchForMergeBlocker(graphP theGraph, K33SearchContext *context, int v, in int _FindK33WithMergeBlocker(graphP theGraph, K33SearchContext *context, int v, int mergeBlocker) { int R, RPrevLink, u_max, u, e; - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; /* First, we orient the vertices so we can successfully restore all of the reduced paths. This needs to be done before reconstructing the context @@ -830,7 +828,7 @@ int _FindK33WithMergeBlocker(graphP theGraph, K33SearchContext *context, int v, /* Reinitialize the visitation, pertinence and future pertinence settings from step u_max for step v */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { gp_SetVertexVisitedInfo(theGraph, v, gp_GetN(theGraph)); gp_SetVertexPertinentEdge(theGraph, v, NIL); @@ -847,7 +845,7 @@ int _FindK33WithMergeBlocker(graphP theGraph, K33SearchContext *context, int v, e = gp_GetVertexFwdEdgeList(theGraph, IC->v); while (gp_IsEdge(theGraph, e)) { - theGraph->functions.fpWalkUp(theGraph, IC->v, e); + theGraph->functions->fpWalkUp(theGraph, IC->v, e); e = gp_GetNextEdge(theGraph, e); if (e == gp_GetVertexFwdEdgeList(theGraph, IC->v)) @@ -984,7 +982,7 @@ int _FindK33WithMergeBlocker(graphP theGraph, K33SearchContext *context, int v, int _TestForZtoWPath(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int v, e, w; sp_ClearStack(theGraph->theStack); @@ -1094,7 +1092,7 @@ int _TestForZtoWPath(graphP theGraph) int _TestForStraddlingBridge(graphP theGraph, K33SearchContext *context, int u_max) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int p, c, d, excludedChild, e; p = IC->v; @@ -1211,7 +1209,7 @@ int _TestForStraddlingBridge(graphP theGraph, K33SearchContext *context, int u_m int _ReduceBicomp(graphP theGraph, K33SearchContext *context, int R) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int min, max, A, A_edge, B, B_edge; int rxType, xwType, wyType, yrType, xyType; @@ -1340,7 +1338,7 @@ int _ReduceBicomp(graphP theGraph, K33SearchContext *context, int R) Case 3. (V, ..., Y=min, ..., W=mid, ..., X=max) Case 4. (V, ..., Y=min, ..., X=mid, ..., W=max) */ - if (theGraph->functions.fpMarkDFSPath(theGraph, R, max) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, R, max) != OK) return NOTOK; /* Now we use A to mark a path on the external face corresponding to: @@ -1349,7 +1347,7 @@ int _ReduceBicomp(graphP theGraph, K33SearchContext *context, int R) Case 3. (V, ..., X=max) Case 4. (V, ..., X=mid) */ - if (theGraph->functions.fpMarkDFSPath(theGraph, min == IC->x ? IC->y : IC->x, A) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, min == IC->x ? IC->y : IC->x, A) != OK) return NOTOK; gp_SetEdgeVisited(theGraph, A_edge); @@ -1362,7 +1360,7 @@ int _ReduceBicomp(graphP theGraph, K33SearchContext *context, int R) Case 3. (Y=min, ..., B, ..., X=max) Case 4. (Y=min, ..., B, ..., W=max) */ - if (theGraph->functions.fpMarkDFSPath(theGraph, max, B) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, max, B) != OK) return NOTOK; gp_SetEdgeVisited(theGraph, B_edge); @@ -1502,7 +1500,8 @@ int _ReduceExternalFacePathToEdge(graphP theGraph, K33SearchContext *context, in not a reduction edge. */ e = gp_GetFirstEdge(theGraph, u); - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e is a reduction edge if it has a pathConnector vertex set + if (context->E[e].pathConnector != NIL) { if (_RestoreReducedPath(theGraph, context, e) != OK) return NOTOK; @@ -1512,7 +1511,8 @@ int _ReduceExternalFacePathToEdge(graphP theGraph, K33SearchContext *context, in _K33Search_DeleteEdge(theGraph, context, e); e = gp_GetLastEdge(theGraph, x); - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e is a reduction edge if it has a pathConnector vertex set + if (context->E[e].pathConnector != NIL) { if (_RestoreReducedPath(theGraph, context, e) != OK) return NOTOK; @@ -1563,7 +1563,8 @@ int _ReduceXYPathToEdge(graphP theGraph, K33SearchContext *context, int u, int x /* Otherwise, remove the two edges that join the XY-path to the bicomp */ - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e is a reduction edge if it has a pathConnector vertex set + if (context->E[e].pathConnector != NIL) { if (_RestoreReducedPath(theGraph, context, e) != OK) return NOTOK; @@ -1576,7 +1577,8 @@ int _ReduceXYPathToEdge(graphP theGraph, K33SearchContext *context, int u, int x e = gp_GetFirstEdge(theGraph, x); e = gp_GetNextEdge(theGraph, e); w = gp_GetNeighbor(theGraph, e); - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e is a reduction edge if it has a pathConnector vertex set + if (context->E[e].pathConnector != NIL) { if (_RestoreReducedPath(theGraph, context, e) != OK) return NOTOK; @@ -1621,7 +1623,9 @@ int _RestoreReducedPath(graphP theGraph, K33SearchContext *context, int e) int eTwin, u, v, w, x; int e0, e1, eTwin0, eTwin1; - if (gp_IsNotAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // Edge e does not represent a reducible path unless it has a + // pathConnect vertex (i.e., a non-NIL value indicating the vertex) + if (context->E[e].pathConnector == NIL) return OK; eTwin = gp_GetTwin(theGraph, e); @@ -1698,13 +1702,13 @@ int _RestoreReducedPath(graphP theGraph, K33SearchContext *context, int e) int _RestoreAndOrientReducedPaths(graphP theGraph, K33SearchContext *context) { - int EsizeOccupied, e, eTwin, u, v, w, x, visited; + int e, eTwin, u, v, w, x, visited; int e0, eTwin0, e1, eTwin1; - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied;) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph);) { - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e is a reduction edge if it has a pathConnector vertex set + if (context->E[e].pathConnector != NIL) { visited = gp_GetEdgeVisited(theGraph, e); @@ -1810,13 +1814,13 @@ int _RestoreAndOrientReducedPaths(graphP theGraph, K33SearchContext *context) int _MarkStraddlingBridgePath(graphP theGraph, int u_min, int u_max, int u_d, int d) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int p, e; /* Find the point of intersection p between the path (v ... u_max) and the path (d ... u_max). */ - if (theGraph->functions.fpMarkDFSPath(theGraph, u_max, IC->r) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, u_max, IC->r) != OK) return NOTOK; p = d; @@ -1883,7 +1887,7 @@ int _MarkStraddlingBridgePath(graphP theGraph, int u_min, int u_max, int u_d, in ancestor of u_min, then mark the path that joins u_d to u_min. */ if (u_d < u_min) - if (theGraph->functions.fpMarkDFSPath(theGraph, u_d, u_min) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, u_d, u_min) != OK) return NOTOK; return OK; @@ -1897,12 +1901,12 @@ int _MarkStraddlingBridgePath(graphP theGraph, int u_min, int u_max, int u_d, in int _IsolateMinorE5(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->x) != OK || _MarkPathAlongBicompExtFace(theGraph, IC->y, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), - MAX3(IC->ux, IC->uy, IC->uz)) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), + MAX3(IC->ux, IC->uy, IC->uz)) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) @@ -1921,7 +1925,7 @@ int _IsolateMinorE5(graphP theGraph) int _IsolateMinorE6(graphP theGraph, K33SearchContext *context) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int u_min, u_max, d, u_d; /* Clear the previously marked x-y path */ @@ -1951,7 +1955,7 @@ int _IsolateMinorE6(graphP theGraph, K33SearchContext *context) /* Make the final markings and edge additions */ - if (theGraph->functions.fpMarkDFSPath(theGraph, u_min, u_max) != OK || + if (theGraph->functions->fpMarkDFSPath(theGraph, u_min, u_max) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK || @@ -1967,7 +1971,7 @@ int _IsolateMinorE6(graphP theGraph, K33SearchContext *context) int _IsolateMinorE7(graphP theGraph, K33SearchContext *context) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int u_min, u_max, d, u_d; /* Mark the appropriate two portions of the external face depending on @@ -1999,7 +2003,7 @@ int _IsolateMinorE7(graphP theGraph, K33SearchContext *context) /* Make the final markings and edge additions */ - if (theGraph->functions.fpMarkDFSPath(theGraph, u_min, u_max) != OK || + if (theGraph->functions->fpMarkDFSPath(theGraph, u_min, u_max) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK || diff --git a/planarity/c/graphLib/homeomorphSearch/graphK33Search.h b/planarity/c/graphLib/homeomorphSearch/graphK33Search.h index 16f7fe6..256f0b2 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK33Search.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK33Search.h @@ -7,13 +7,15 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graphStructures.h" +#include "../planarityRelated/graphPlanarity.h" #ifdef __cplusplus extern "C" { #endif +// Create a K33Search Graph, i.e., subclass a Planarity Graph by extending it with +// the ability to perform a search for a subgraph homeomorphic to K_{3,3}. #define K33SEARCH_NAME "K33Search" int gp_ExtendWith_K33Search(graphP theGraph); diff --git a/planarity/c/graphLib/homeomorphSearch/graphK33Search.private.h b/planarity/c/graphLib/homeomorphSearch/graphK33Search.private.h index e489532..1fae397 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK33Search.private.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK33Search.private.h @@ -7,7 +7,7 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "../planarityRelated/graphPlanarity.private.h" #ifdef __cplusplus extern "C" @@ -51,7 +51,7 @@ extern "C" listCollectionP bin; // Overloaded function pointers - graphFunctionTable functions; + graphFunctionTableStruct functions; } K33SearchContext; diff --git a/planarity/c/graphLib/homeomorphSearch/graphK33Search_Extensions.c b/planarity/c/graphLib/homeomorphSearch/graphK33Search_Extensions.c index db480e9..aa7b955 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK33Search_Extensions.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK33Search_Extensions.c @@ -6,8 +6,11 @@ See the LICENSE.TXT file for licensing information. #include -#include "graphK33Search.private.h" #include "graphK33Search.h" +#include "graphK33Search.private.h" + +// Need to save and restore a graph flag related to IO +#include "../io/graphIO.h" extern int _SearchForMergeBlocker(graphP theGraph, K33SearchContext *context, int v, int *pMergeBlocker); extern int _FindK33WithMergeBlocker(graphP theGraph, K33SearchContext *context, int v, int mergeBlocker); @@ -41,7 +44,7 @@ int _K33Search_CheckEmbeddingIntegrity(graphP theGraph, graphP origGraph); int _K33Search_CheckObstructionIntegrity(graphP theGraph, graphP origGraph); int _K33Search_InitGraph(graphP theGraph, int N); -void _K33Search_ReinitializeGraph(graphP theGraph); +void _K33Search_ReinitGraph(graphP theGraph); int _K33Search_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity); /* Forward declarations of functions used by the extension system */ @@ -68,6 +71,9 @@ int gp_ExtendWith_K33Search(graphP theGraph) { K33SearchContext *context = NULL; + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + // If the K3,3 search feature has already been attached to the graph, // then there is no need to attach it again gp_FindExtension(theGraph, K33SEARCH_ID, (void *)&context); @@ -76,6 +82,10 @@ int gp_ExtendWith_K33Search(graphP theGraph) return OK; } + // Ensure theGraph is a Planarity Graph + if (gp_ExtendWith_Planarity(theGraph) != OK) + return NOTOK; + // Allocate a new extension context context = (K33SearchContext *)malloc(sizeof(K33SearchContext)); if (context == NULL) @@ -92,7 +102,7 @@ int gp_ExtendWith_K33Search(graphP theGraph) // Put the overload functions into the context function table. // gp_AddExtension will overload the graph's functions with these, and // return the base function pointers in the context function table - memset(&context->functions, 0, sizeof(graphFunctionTable)); + memset(&context->functions, 0, sizeof(graphFunctionTableStruct)); context->functions.fpEmbeddingInitialize = _K33Search_EmbeddingInitialize; context->functions.fpEmbedBackEdgeToDescendant = _K33Search_EmbedBackEdgeToDescendant; @@ -104,7 +114,7 @@ int gp_ExtendWith_K33Search(graphP theGraph) context->functions.fpCheckObstructionIntegrity = _K33Search_CheckObstructionIntegrity; context->functions.fpInitGraph = _K33Search_InitGraph; - context->functions.fpReinitializeGraph = _K33Search_ReinitializeGraph; + context->functions.fpReinitGraph = _K33Search_ReinitGraph; context->functions.fpEnsureEdgeCapacity = _K33Search_EnsureEdgeCapacity; _K33Search_ClearStructures(context); @@ -200,8 +210,8 @@ void _K33Search_ClearStructures(K33SearchContext *context) ********************************************************************/ int _K33Search_CreateStructures(K33SearchContext *context) { - int VIsize = gp_VertexArraySize(context->theGraph); - int Esize = gp_EdgeArraySize(context->theGraph); + int VIsize = gp_UpperBoundVertices(context->theGraph); + int Esize = gp_UpperBoundEdgeStorage(context->theGraph); if (gp_GetN(context->theGraph) <= 0) return NOTOK; @@ -223,22 +233,8 @@ int _K33Search_CreateStructures(K33SearchContext *context) ********************************************************************/ int _K33Search_InitStructures(K33SearchContext *context) { - memset(context->VI, NIL_CHAR, gp_VertexArraySize(context->theGraph) * sizeof(K33Search_VertexInfo)); - memset(context->E, NIL_CHAR, gp_EdgeArraySize(context->theGraph) * sizeof(K33Search_EdgeRec)); - // N.B. This is the legacy API-based approach to initializing the structures - // required for the K_{3, 3} search graph algorithm extension. - // graphP theGraph = context->theGraph; - // int v, e, Esize; - - // if (gp_GetN(theGraph) <= 0) - // return OK; - - // for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) - // _K33Search_InitVertexInfo(context, v); - - // Esize = gp_EdgeArraySize(theGraph); - // for (e = gp_EdgeArrayStart(theGraph); e < Esize; e++) - // _K33Search_InitEdgeRec(context, e); + memset(context->VI, NIL_CHAR, gp_UpperBoundVertices(context->theGraph) * sizeof(K33Search_VertexInfo)); + memset(context->E, NIL_CHAR, gp_UpperBoundEdgeStorage(context->theGraph) * sizeof(K33Search_EdgeRec)); return OK; } @@ -259,7 +255,7 @@ int _K33Search_InitGraph(graphP theGraph, int N) theGraph->N = N; theGraph->NV = N; if (theGraph->edgeCapacity == 0) - theGraph->edgeCapacity = DEFAULT_EDGE_LIMIT * N; + theGraph->edgeCapacity = DEFAULT_EDGE_CAPACITY_FACTOR * N; if (_K33Search_CreateStructures(context) != OK || _K33Search_InitStructures(context) != OK) @@ -273,7 +269,7 @@ int _K33Search_InitGraph(graphP theGraph, int N) /******************************************************************** ********************************************************************/ -void _K33Search_ReinitializeGraph(graphP theGraph) +void _K33Search_ReinitGraph(graphP theGraph) { K33SearchContext *context = NULL; gp_FindExtension(theGraph, K33SEARCH_ID, (void *)&context); @@ -281,7 +277,7 @@ void _K33Search_ReinitializeGraph(graphP theGraph) if (context != NULL) { // Reinitialize the graph - context->functions.fpReinitializeGraph(theGraph); + context->functions.fpReinitGraph(theGraph); // Do the reinitialization that is specific to this module _K33Search_InitStructures(context); @@ -316,8 +312,8 @@ void *_K33Search_DupContext(void *pContext, void *theGraph) if (newContext != NULL) { - int VIsize = gp_VertexArraySize((graphP)theGraph); - int Esize = gp_EdgeArraySize((graphP)theGraph); + int VIsize = gp_UpperBoundVertices((graphP)theGraph); + int Esize = gp_UpperBoundEdgeStorage((graphP)theGraph); *newContext = *context; @@ -394,7 +390,7 @@ void _CreateBackEdgeLists(graphP theGraph, K33SearchContext *context) { int v, e, eTwin, ancestor; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { e = gp_GetVertexFwdEdgeList(theGraph, v); while (gp_IsEdge(theGraph, e)) @@ -445,12 +441,12 @@ void _CreateSeparatedDFSChildLists(graphP theGraph, K33SearchContext *context) // Initialize the bin and all the buckets to be empty LCReset(bin); - for (L = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, L); L++) + for (L = gp_LowerBoundVertices(theGraph); L < gp_UpperBoundVertices(theGraph); L++) buckets[L] = NIL; // For each vertex, add it to the bucket whose index is equal to the lowpoint of the vertex. - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { L = gp_GetVertexLowpoint(theGraph, v); buckets[L] = LCAppend(bin, buckets[L], v); @@ -460,7 +456,7 @@ void _CreateSeparatedDFSChildLists(graphP theGraph, K33SearchContext *context) // Since lower numbered buckets are processed before higher numbered buckets, vertices with lower // lowpoint values are added before those with higher lowpoint values, so the separatedDFSChildList // of each vertex is sorted by lowpoint - for (L = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, L); L++) + for (L = gp_LowerBoundVertices(theGraph); L < gp_UpperBoundVertices(theGraph); L++) { v = buckets[L]; @@ -680,8 +676,8 @@ int _K33Search_EmbedPostprocess(graphP theGraph, int v, int edgeEmbeddingResult) // is meaningless, so we empty it out. We preserve the embedFlags // to ensure post-processing continues as expected. savedEmbedFlags = gp_GetEmbedFlags(theGraph); - savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & FLAGS_ZEROBASEDIO; - gp_ReinitializeGraph(theGraph); + savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & GRAPHFLAGS_ZEROBASEDIO; + gp_ReinitGraph(theGraph); theGraph->embedFlags = savedEmbedFlags; theGraph->graphFlags &= savedZEROBASEDIO; } diff --git a/planarity/c/graphLib/homeomorphSearch/graphK4Search.c b/planarity/c/graphLib/homeomorphSearch/graphK4Search.c index 291ef32..1081fb7 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK4Search.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK4Search.c @@ -7,8 +7,6 @@ See the LICENSE.TXT file for licensing information. #include "graphK4Search.h" #include "graphK4Search.private.h" -#include "../graph.h" - /* Imported functions */ extern void _InitIsolatorContext(graphP theGraph); @@ -88,7 +86,7 @@ int _K4_RestoreAndOrientReducedPaths(graphP theGraph, K4SearchContext *context); int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (context == NULL) { @@ -105,7 +103,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R // we run additional tests to see whether we can either find an // entwined K4 homeomorph or reduce the bicomp so that the WalkDown // is enabled to continue to resolve pertinence - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) { // Now that we know we have minor A, we can afford to orient the // bicomp because we will either find the desired K4 or we will @@ -185,7 +183,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R return NOTOK; // If there was an X-Y path to mark... - if (theGraph->IC.py != NIL) + if (theGraph->IC->py != NIL) { // Now that we know we can find a K4, the Walkdown will not continue // and we can do away with the stack content. @@ -207,7 +205,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R } // Fail if there is an internal error or if there isn't an X-Y path - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; // Isolate the K4 homeomorph @@ -243,7 +241,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R // we run additional tests to see whether we can either find an // entwined K4 homeomorph or reduce a portion of the bicomp so that // the WalkDown can be reinvoked on the bicomp - else if (theGraph->IC.minorType & MINORTYPE_B) + else if (theGraph->IC->minorType & MINORTYPE_B) { int a_x, a_y; @@ -320,7 +318,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R // the separating internal edge (but it has to be there, else error). if (_SetVertexTypesForMarkingXYPath(theGraph) != OK || _MarkHighestXYPath(theGraph) != OK || - theGraph->IC.py == NIL) + theGraph->IC->py == NIL) return NOTOK; // Isolate the K4 homeomorph @@ -355,7 +353,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R } // Minor E indicates the desired K4 homeomorph, so we isolate it and return NONEMBEDDABLE - else if (theGraph->IC.minorType & MINORTYPE_E) + else if (theGraph->IC->minorType & MINORTYPE_E) { // Reality check on stack state if (sp_NonEmpty(theGraph->theStack)) @@ -375,7 +373,7 @@ int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R if (_SetVertexTypesForMarkingXYPath(theGraph) != OK) return NOTOK; - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; // Isolate the K4 homeomorph @@ -410,8 +408,8 @@ int _K4_ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) _InitIsolatorContext(theGraph); - theGraph->IC.v = v; - theGraph->IC.r = R; + theGraph->IC->v = v; + theGraph->IC->r = R; // Reality check on data structure integrity if (!gp_VirtualVertexInUse(theGraph, R)) @@ -422,8 +420,8 @@ int _K4_ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) // are the desired vertices because no vertices are "inactive" // 2) We have purposely not oriented the bicomp, so the XPrevLink result is // needed to help find the pertinent vertex W - theGraph->IC.x = _GetNeighborOnExtFace(theGraph, R, &XPrevLink); - theGraph->IC.y = _GetNeighborOnExtFace(theGraph, R, &YPrevLink); + theGraph->IC->x = _GetNeighborOnExtFace(theGraph, R, &XPrevLink); + theGraph->IC->y = _GetNeighborOnExtFace(theGraph, R, &YPrevLink); // We are essentially doing a _FindPertinentVertex() here, except two things: // 1) It is not known whether the reduction of the path through X or the path @@ -435,45 +433,45 @@ int _K4_ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) // the "prev link" is hard coded to traverse down the X side. In this // implementation, the bicomp is purposely not oriented, so we need to know // XPrevLink and YPrevLink in order to set off in the correct directions. - Wx = theGraph->IC.x; + Wx = theGraph->IC->x; WxPrevLink = XPrevLink; - Wy = theGraph->IC.y; + Wy = theGraph->IC->y; WyPrevLink = YPrevLink; - theGraph->IC.w = NIL; + theGraph->IC->w = NIL; - while (Wx != theGraph->IC.y) + while (Wx != theGraph->IC->y) { Wx = _GetNeighborOnExtFace(theGraph, Wx, &WxPrevLink); if (PERTINENT(theGraph, Wx)) { - theGraph->IC.w = Wx; + theGraph->IC->w = Wx; break; } Wy = _GetNeighborOnExtFace(theGraph, Wy, &WyPrevLink); if (PERTINENT(theGraph, Wy)) { - theGraph->IC.w = Wy; + theGraph->IC->w = Wy; break; } } - if (gp_IsNotVertex(theGraph, theGraph->IC.w)) + if (gp_IsNotVertex(theGraph, theGraph->IC->w)) return NOTOK; // If the root copy is not a root copy of the current vertex v, // then the Walkdown terminated on a descendant bicomp, which is Minor A. if (gp_GetVertexFromBicompRoot(theGraph, R) != v) - theGraph->IC.minorType |= MINORTYPE_A; + theGraph->IC->minorType |= MINORTYPE_A; // If W has a pertinent child bicomp, then we've found Minor B. // Notice this is different from planarity, in which minor B is indicated // only if the pertinent child bicomp is also future pertinent. - else if (gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theGraph->IC.w))) - theGraph->IC.minorType |= MINORTYPE_B; + else if (gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theGraph->IC->w))) + theGraph->IC->minorType |= MINORTYPE_B; // The only other result is minor E (we will search for the X-Y path later) else - theGraph->IC.minorType |= MINORTYPE_E; + theGraph->IC->minorType |= MINORTYPE_E; return OK; } @@ -493,16 +491,16 @@ int _K4_ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) int _K4_FindSecondActiveVertexOnLowExtFacePath(graphP theGraph) { - int Z = theGraph->IC.r, ZPrevLink = 1; + int Z = theGraph->IC->r, ZPrevLink = 1; // First we test X for future pertinence only (if it were pertinent, then // we wouldn't have been blocked up on this bicomp) Z = _GetNeighborOnExtFace(theGraph, Z, &ZPrevLink); - gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, Z, theGraph->IC.v)) + gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, Z, theGraph->IC->v)) { - theGraph->IC.z = Z; - theGraph->IC.uz = _GetLeastAncestorConnection(theGraph, Z); + theGraph->IC->z = Z; + theGraph->IC->uz = _GetLeastAncestorConnection(theGraph, Z); return TRUE; } @@ -511,21 +509,21 @@ int _K4_FindSecondActiveVertexOnLowExtFacePath(graphP theGraph) // future pertinence. Z = _GetNeighborOnExtFace(theGraph, Z, &ZPrevLink); - while (Z != theGraph->IC.y) + while (Z != theGraph->IC->y) { - if (Z != theGraph->IC.w) + if (Z != theGraph->IC->w) { - gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, Z, theGraph->IC.v)) + gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, Z, theGraph->IC->v)) { - theGraph->IC.z = Z; - theGraph->IC.uz = _GetLeastAncestorConnection(theGraph, Z); + theGraph->IC->z = Z; + theGraph->IC->uz = _GetLeastAncestorConnection(theGraph, Z); return TRUE; } else if (PERTINENT(theGraph, Z)) { - theGraph->IC.z = Z; - theGraph->IC.uz = theGraph->IC.v; + theGraph->IC->z = Z; + theGraph->IC->uz = theGraph->IC->v; return TRUE; } } @@ -534,11 +532,11 @@ int _K4_FindSecondActiveVertexOnLowExtFacePath(graphP theGraph) } // Now we test Y for future pertinence (same explanation as for X above) - gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC.v); - if (FUTUREPERTINENT(theGraph, Z, theGraph->IC.v)) + gp_UpdateVertexFuturePertinentChild(theGraph, Z, theGraph->IC->v); + if (FUTUREPERTINENT(theGraph, Z, theGraph->IC->v)) { - theGraph->IC.z = Z; - theGraph->IC.uz = _GetLeastAncestorConnection(theGraph, Z); + theGraph->IC->z = Z; + theGraph->IC->uz = _GetLeastAncestorConnection(theGraph, Z); return TRUE; } @@ -717,15 +715,15 @@ void _K4_ClearMarksOnExternalFacePath(graphP theGraph, int R, int prevLink, int int _K4_IsolateMinorA1(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (IC->uz < IC->v) { - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->uz, IC->v) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->uz, IC->v) != OK) return NOTOK; } - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->z, IC->dz) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->z, IC->dz) != OK) return NOTOK; if (_IsolateOuterplanarityObstructionA(theGraph) != OK) @@ -754,7 +752,7 @@ int _K4_IsolateMinorA1(graphP theGraph) int _K4_IsolateMinorA2(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; // We assume the X-Y path was already marked if (!gp_GetVisited(theGraph, IC->px) || !gp_GetVisited(theGraph, IC->py)) @@ -781,18 +779,18 @@ int _K4_IsolateMinorA2(graphP theGraph) int _K4_IsolateMinorB1(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->x, IC->dx) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->x, IC->dx) != OK) return NOTOK; - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->y, IC->dy) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->y, IC->dy) != OK) return NOTOK; // The path from the bicomp root to MIN(ux,uy) is marked to ensure the // connection from the image vertices v and MAX(ux,uy) as well as the // connection from MAX(ux,uy) through MIN(ux,uy) to (ux==MIN(ux,uy)?x:y) - if (theGraph->functions.fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK) return NOTOK; // This makes the following connections (a_x ... v), (a_y ... v), and @@ -823,7 +821,7 @@ int _K4_IsolateMinorB1(graphP theGraph) int _K4_IsolateMinorB2(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; // First subcase, the active vertex is pertinent if (PERTINENT(theGraph, IC->w)) @@ -868,7 +866,7 @@ int _K4_ReduceBicompToEdge(graphP theGraph, K4SearchContext *context, int R, int if (_OrientVerticesInBicomp(theGraph, R, 0) != OK || _ClearAllVisitedFlagsInBicomp(theGraph, R) != OK) return NOTOK; - if (theGraph->functions.fpMarkDFSPath(theGraph, R, W) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, R, W) != OK) return NOTOK; if (_K4_DeleteUnmarkedEdgesInBicomp(theGraph, context, R) != OK) return NOTOK; @@ -953,7 +951,7 @@ int _K4_ReducePathComponent(graphP theGraph, K4SearchContext *context, int R, in if (_K4_TestPathComponentForAncestor(theGraph, R, prevLink, A)) { _K4_ClearVisitedInPathComponent(theGraph, R, prevLink, A); - if (theGraph->functions.fpMarkDFSPath(theGraph, R, A) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, R, A) != OK) return NOTOK; edgeType = EDGE_TYPE_PARENT; @@ -967,7 +965,7 @@ int _K4_ReducePathComponent(graphP theGraph, K4SearchContext *context, int R, in Z = gp_GetNeighbor(theGraph, e_R); gp_SetEdgeVisited(theGraph, e_R); gp_SetEdgeVisited(theGraph, gp_GetTwin(theGraph, e_R)); - if (theGraph->functions.fpMarkDFSPath(theGraph, A, Z) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, A, Z) != OK) { return NOTOK; } @@ -1082,7 +1080,7 @@ int _K4_GetCumulativeOrientationOnDFSPath(graphP theGraph, int ancestor, int des while (descendant != ancestor) { - if (gp_IsNotAnyTypeVertex(theGraph, descendant)) + if (descendant == NIL) return NOTOK; // If we are at a bicomp root, then ascend to its parent copy @@ -1108,7 +1106,7 @@ int _K4_GetCumulativeOrientationOnDFSPath(graphP theGraph, int ancestor, int des } // If the edge to the parent vertex was not found, then the data structure is corrupt - if (gp_IsNotAnyTypeVertex(theGraph, parent)) + if (parent == NIL) return NOTOK; // Add the inversion flag on the child edge record to the cumulative result @@ -1288,7 +1286,9 @@ int _K4_ReducePathToEdge(graphP theGraph, K4SearchContext *context, int edgeType // Prepare for removing each of the two edges that join the path to the bicomp by // restoring it if it is a reduction edge (a constant time operation) - if (gp_IsAnyTypeVertex(theGraph, context->E[e_R].pathConnector)) + // If e_R has a pathConnector vertex, then we prep by restoring a previously reduced + // path for e_R + if (context->E[e_R].pathConnector != NIL) { if (_K4_RestoreReducedPath(theGraph, context, e_R) != OK) { @@ -1301,7 +1301,9 @@ int _K4_ReducePathToEdge(graphP theGraph, K4SearchContext *context, int edgeType e_R = gp_GetEdgeByLink(theGraph, R, Rlink); } - if (gp_IsAnyTypeVertex(theGraph, context->E[e_A].pathConnector)) + // If e_A has a pathConnector vertex, then we prep by restoring a previously reduced + // path for e_A + if (context->E[e_A].pathConnector != NIL) { if (_K4_RestoreReducedPath(theGraph, context, e_A) != OK) { @@ -1378,7 +1380,9 @@ int _K4_RestoreReducedPath(graphP theGraph, K4SearchContext *context, int e) int eTwin, u, v, w, x; int e0, e1, eTwin0, eTwin1; - if (gp_IsNotAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // An edge e does not represent a path reduction that needs to be restored + // unless it was assigned a pathConnector vertex (and so is non-NIL) + if (context->E[e].pathConnector == NIL) return OK; eTwin = gp_GetTwin(theGraph, e); @@ -1453,12 +1457,13 @@ int _K4_RestoreReducedPath(graphP theGraph, K4SearchContext *context, int e) int _K4_RestoreAndOrientReducedPaths(graphP theGraph, K4SearchContext *context) { - int EsizeOccupied, e, eTwin, u, v, w, x, visited; + int e, eTwin, u, v, w, x, visited; - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied;) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph);) { - if (gp_IsAnyTypeVertex(theGraph, context->E[e].pathConnector)) + // If e has a pathConnector vertex, then there is a reduced path + // to restore and orient. + if (context->E[e].pathConnector != NIL) { visited = gp_GetEdgeVisited(theGraph, e); diff --git a/planarity/c/graphLib/homeomorphSearch/graphK4Search.h b/planarity/c/graphLib/homeomorphSearch/graphK4Search.h index ddc4427..660ee15 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK4Search.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK4Search.h @@ -7,13 +7,15 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graphStructures.h" +#include "../planarityRelated/graphOuterplanarity.h" #ifdef __cplusplus extern "C" { #endif +// Create a K4Search Graph, i.e., subclass an Outerplanarity Graph by extending it +// with the ability to perform a search for a subgraph homeomorphic to K_4. #define K4SEARCH_NAME "K4Search" int gp_ExtendWith_K4Search(graphP theGraph); diff --git a/planarity/c/graphLib/homeomorphSearch/graphK4Search.private.h b/planarity/c/graphLib/homeomorphSearch/graphK4Search.private.h index 9f170bb..7886fe0 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK4Search.private.h +++ b/planarity/c/graphLib/homeomorphSearch/graphK4Search.private.h @@ -7,7 +7,7 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "../planarityRelated/graphOuterplanarity.private.h" #ifdef __cplusplus extern "C" @@ -47,7 +47,7 @@ extern "C" K4Search_EdgeRecP E; // Overloaded function pointers - graphFunctionTable functions; + graphFunctionTableStruct functions; // Internal variable for converting a tail recursion into a simple loop int handlingBlockedBicomp; diff --git a/planarity/c/graphLib/homeomorphSearch/graphK4Search_Extensions.c b/planarity/c/graphLib/homeomorphSearch/graphK4Search_Extensions.c index a89584b..211f3ed 100644 --- a/planarity/c/graphLib/homeomorphSearch/graphK4Search_Extensions.c +++ b/planarity/c/graphLib/homeomorphSearch/graphK4Search_Extensions.c @@ -6,8 +6,11 @@ See the LICENSE.TXT file for licensing information. #include -#include "graphK4Search.private.h" #include "graphK4Search.h" +#include "graphK4Search.private.h" + +// Need to save and restore a graph flag related to IO +#include "../io/graphIO.h" extern int _SearchForK4InBicomp(graphP theGraph, K4SearchContext *context, int v, int R); @@ -34,7 +37,7 @@ int _K4Search_CheckEmbeddingIntegrity(graphP theGraph, graphP origGraph); int _K4Search_CheckObstructionIntegrity(graphP theGraph, graphP origGraph); int _K4Search_InitGraph(graphP theGraph, int N); -void _K4Search_ReinitializeGraph(graphP theGraph); +void _K4Search_ReinitGraph(graphP theGraph); int _K4Search_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity); /* Forward declarations of functions used by the extension system */ @@ -61,6 +64,9 @@ int gp_ExtendWith_K4Search(graphP theGraph) { K4SearchContext *context = NULL; + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + // If the K4 search feature has already been attached to the graph, // then there is no need to attach it again gp_FindExtension(theGraph, K4SEARCH_ID, (void *)&context); @@ -69,6 +75,10 @@ int gp_ExtendWith_K4Search(graphP theGraph) return OK; } + // Ensure theGraph is an Outerplanarity Graph + if (gp_ExtendWith_Outerplanarity(theGraph) != OK) + return NOTOK; + // Allocate a new extension context context = (K4SearchContext *)malloc(sizeof(K4SearchContext)); if (context == NULL) @@ -85,14 +95,14 @@ int gp_ExtendWith_K4Search(graphP theGraph) // Put the overload functions into the context function table. // gp_AddExtension will overload the graph's functions with these, and // return the base function pointers in the context function table - memset(&context->functions, 0, sizeof(graphFunctionTable)); + memset(&context->functions, 0, sizeof(graphFunctionTableStruct)); context->functions.fpHandleBlockedBicomp = _K4Search_HandleBlockedBicomp; context->functions.fpEmbedPostprocess = _K4Search_EmbedPostprocess; context->functions.fpCheckEmbeddingIntegrity = _K4Search_CheckEmbeddingIntegrity; context->functions.fpCheckObstructionIntegrity = _K4Search_CheckObstructionIntegrity; context->functions.fpInitGraph = _K4Search_InitGraph; - context->functions.fpReinitializeGraph = _K4Search_ReinitializeGraph; + context->functions.fpReinitGraph = _K4Search_ReinitGraph; context->functions.fpEnsureEdgeCapacity = _K4Search_EnsureEdgeCapacity; _K4Search_ClearStructures(context); @@ -173,12 +183,10 @@ void _K4Search_ClearStructures(K4SearchContext *context) ********************************************************************/ int _K4Search_CreateStructures(K4SearchContext *context) { - int Esize = gp_EdgeArraySize(context->theGraph); - if (gp_GetN(context->theGraph) <= 0) return NOTOK; - if ((context->E = (K4Search_EdgeRecP)malloc(Esize * sizeof(K4Search_EdgeRec))) == NULL || + if ((context->E = (K4Search_EdgeRecP)malloc(gp_UpperBoundEdgeStorage(context->theGraph) * sizeof(K4Search_EdgeRec))) == NULL || 0) { return NOTOK; @@ -192,14 +200,7 @@ int _K4Search_CreateStructures(K4SearchContext *context) ********************************************************************/ int _K4Search_InitStructures(K4SearchContext *context) { - memset(context->E, NIL_CHAR, gp_EdgeArraySize(context->theGraph) * sizeof(K4Search_EdgeRec)); - // N.B. This is the legacy API-based approach to initializing the structures - // required for the K_4 search graph algorithm extension. - // int e, Esize; - - // Esize = gp_EdgeArraySize(context->theGraph); - // for (e = gp_EdgeArrayStart(context->theGraph); e < Esize; e++) - // _K4Search_InitEdgeRec(context, e); + memset(context->E, NIL_CHAR, gp_UpperBoundEdgeStorage(context->theGraph) * sizeof(K4Search_EdgeRec)); return OK; } @@ -218,7 +219,7 @@ int _K4Search_InitGraph(graphP theGraph, int N) theGraph->N = N; theGraph->NV = N; if (theGraph->edgeCapacity == 0) - theGraph->edgeCapacity = DEFAULT_EDGE_LIMIT * N; + theGraph->edgeCapacity = DEFAULT_EDGE_CAPACITY_FACTOR * N; if (_K4Search_CreateStructures(context) != OK || _K4Search_InitStructures(context) != OK) @@ -232,7 +233,7 @@ int _K4Search_InitGraph(graphP theGraph, int N) /******************************************************************** ********************************************************************/ -void _K4Search_ReinitializeGraph(graphP theGraph) +void _K4Search_ReinitGraph(graphP theGraph) { K4SearchContext *context = NULL; gp_FindExtension(theGraph, K4SEARCH_ID, (void *)&context); @@ -240,7 +241,7 @@ void _K4Search_ReinitializeGraph(graphP theGraph) if (context != NULL) { // Reinitialize the graph - context->functions.fpReinitializeGraph(theGraph); + context->functions.fpReinitGraph(theGraph); // Do the reinitialization that is specific to this module _K4Search_InitStructures(context); @@ -273,7 +274,7 @@ void *_K4Search_DupContext(void *pContext, void *theGraph) if (newContext != NULL) { - int Esize = gp_EdgeArraySize((graphP)theGraph); + int Esize = gp_UpperBoundEdgeStorage((graphP)theGraph); *newContext = *context; @@ -354,7 +355,7 @@ int _K4Search_HandleBlockedBicomp(graphP theGraph, int v, int RootVertex, int R) sp_Pop2_Discard1(theGraph->theStack, R); // And we have to clear the indicator of the minor A that was reduced, since it was eliminated. - theGraph->IC.minorType = 0; + theGraph->IC->minorType = MINORTYPE_NONE; } } @@ -386,13 +387,13 @@ int _K4Search_HandleBlockedBicomp(graphP theGraph, int v, int RootVertex, int R) // detects that it still has not embedded all the edges to descendants of the bicomp's // root edge child, then Walkdown calls this routine again, and the above non-reentrancy // code returns NONEMBEDDABLE, causing this loop to search again for a K4. - theGraph->IC.minorType = 0; - RetVal = theGraph->functions.fpWalkDown(theGraph, v, RootVertex); + theGraph->IC->minorType = MINORTYPE_NONE; + RetVal = theGraph->functions->fpWalkDown(theGraph, v, RootVertex); // Except if the Walkdown returns NONEMBEDDABLE due to finding a K4 homeomorph entangled // with a descendant bicomp (the R != RootVertex case above), then it was found // entangled with Minor A, so we can stop the search if minor A is detected - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) break; } while (RetVal == NONEMBEDDABLE); @@ -427,8 +428,8 @@ int _K4Search_EmbedPostprocess(graphP theGraph, int v, int edgeEmbeddingResult) // is meaningless, so we empty it out. We preserve the embedFlags // to ensure post-processing continues as expected. savedEmbedFlags = gp_GetEmbedFlags(theGraph); - savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & FLAGS_ZEROBASEDIO; - gp_ReinitializeGraph(theGraph); + savedZEROBASEDIO = gp_GetGraphFlags(theGraph) & GRAPHFLAGS_ZEROBASEDIO; + gp_ReinitGraph(theGraph); theGraph->embedFlags = savedEmbedFlags; theGraph->graphFlags &= savedZEROBASEDIO; } diff --git a/planarity/c/graphLib/io/g6-api-utilities.c b/planarity/c/graphLib/io/g6-api-utilities.c index 9eabf35..e65aa37 100644 --- a/planarity/c/graphLib/io/g6-api-utilities.c +++ b/planarity/c/graphLib/io/g6-api-utilities.c @@ -8,9 +8,9 @@ See the LICENSE.TXT file for licensing information. #include "../lowLevelUtils/appconst.h" /* Private function declarations (exported within system) */ -int _g6_GetNumCharsForEncoding(int); -int _g6_GetNumCharsForOrder(int); -int _g6_GetExpectedNumPaddingZeroes(const int, const int); +size_t _g6_GetNumCharsForEncoding(int order); +int _g6_GetNumCharsForOrder(int order); +size_t _g6_GetExpectedNumPaddingZeroes(const int order, const size_t numChars); // NOTE: this method is used by g6_ReadGraph() to ensure that graphs after the // first one in the file have the same order, and by g6_WriteGraph() to ensure // that the encoding of the graph order at the beginning of the graph encoding @@ -22,19 +22,19 @@ int _g6_ValidateOrderOfEncodedGraph(char *graphBuff, int order); // NOTE: this method is now used to validate each graph we're reading in, as // well as to check the validity of the encoding produced before attempting to // write. -int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numChars); +int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const size_t numChars); /* Private functions */ -int _g6_GetMaxEdgeCount(int); +size_t _g6_GetMaxEdgeCount(int); -int _g6_GetMaxEdgeCount(int order) +size_t _g6_GetMaxEdgeCount(int order) { - return (order * (order - 1)) / 2; + return ((size_t)order * (order - 1)) / 2; } -int _g6_GetNumCharsForEncoding(int order) +size_t _g6_GetNumCharsForEncoding(int order) { - int maxNumEdges = _g6_GetMaxEdgeCount(order); + size_t maxNumEdges = _g6_GetMaxEdgeCount(order); return (maxNumEdges / 6) + (maxNumEdges % 6 ? 1 : 0); } @@ -53,10 +53,10 @@ int _g6_GetNumCharsForOrder(int order) return -1; } -int _g6_GetExpectedNumPaddingZeroes(const int order, const int numChars) +size_t _g6_GetExpectedNumPaddingZeroes(const int order, const size_t numChars) { - int maxNumEdges = _g6_GetMaxEdgeCount(order); - int expectedNumPaddingZeroes = numChars * 6 - maxNumEdges; + size_t maxNumEdges = _g6_GetMaxEdgeCount(order); + size_t expectedNumPaddingZeroes = numChars * 6 - maxNumEdges; return expectedNumPaddingZeroes; } @@ -70,12 +70,12 @@ int _g6_ValidateOrderOfEncodedGraph(char *graphBuff, int order) { if (graphBuff[1] == 126) { - ErrorMessage("Can only handle graphs of order <= 100,000.\n"); + gp_ErrorMessage("Can only handle graphs of order <= 100,000.\n"); return NOTOK; } else if (graphBuff[1] > 126) { - ErrorMessage("Invalid graph order signifier.\n"); + gp_ErrorMessage("Invalid graph order signifier.\n"); return NOTOK; } else @@ -89,32 +89,32 @@ int _g6_ValidateOrderOfEncodedGraph(char *graphBuff, int order) n = currChar - 63; else { - ErrorMessage("Character doesn't correspond to a printable ASCII character.\n"); + gp_ErrorMessage("Character doesn't correspond to a printable ASCII " + "character.\n"); return NOTOK; } if (n != order) { - char messageContents[MAXLINE + 1]; - sprintf(messageContents, "Graph order %d doesn't match expected graph order %d", n, order); - ErrorMessage(messageContents); + gp_ErrorMessage("Graph order %d doesn't match expected graph order %d", + n, order); return NOTOK; } return OK; } -int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numChars) +int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const size_t numChars) { int exitCode = OK; - int numPaddingZeroes = 0, numCharsForGraphEncoding = 0; - int expectedNumPaddingZeroes = 0, expectedNumChars = 0; + size_t numPaddingZeroes = 0, numCharsForGraphEncoding = 0; + size_t expectedNumPaddingZeroes = 0, expectedNumChars = 0; char finalByte = '\0'; if (graphBuff == NULL || strlen(graphBuff) == 0) { - ErrorMessage("Invalid encoding: graphBuff is NULL or has no content.\n"); + gp_ErrorMessage("Invalid encoding: graphBuff is NULL or empty.\n"); return NOTOK; } @@ -129,29 +129,26 @@ int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numCha if (expectedNumChars != numCharsForGraphEncoding) { - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; - sprintf(messageContents, "Invalid number of bytes for graph of order %d; got %d but expected %d\n", order, numCharsForGraphEncoding, expectedNumChars); - ErrorMessage(messageContents); + gp_ErrorMessage("Invalid number of bytes for graph of order %d; got %d " + "but expected %d\n", + order, (int)numCharsForGraphEncoding, (int)expectedNumChars); return NOTOK; } // Check that characters are valid ASCII characters between 62 and 126 - for (int i = 0; i < numChars; i++) + for (size_t i = 0; i < numChars; i++) { if (graphBuff[i] < 63 || graphBuff[i] > 126) { - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; - sprintf(messageContents, "Invalid character at index %d: \"%c\"\n", i, graphBuff[i]); - ErrorMessage(messageContents); + gp_ErrorMessage("Invalid character at index %d: \"%c\"\n", + (int)i, graphBuff[i]); return NOTOK; } } // Check that there are no extraneous bits in representation (since we pad out to a // multiple of 6 before splitting into bytes and adding 63 to each byte) - for (int i = 0; i < expectedNumPaddingZeroes; i++) + for (size_t i = 0; i < expectedNumPaddingZeroes; i++) { if (finalByte & (1 << i)) break; @@ -161,10 +158,8 @@ int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numCha if (numPaddingZeroes != expectedNumPaddingZeroes) { - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; - sprintf(messageContents, "Expected %d padding zeroes, but got %d.\n", expectedNumPaddingZeroes, numPaddingZeroes); - ErrorMessage(messageContents); + gp_ErrorMessage("Expected %d padding zeroes, but got %d.\n", + (int)expectedNumPaddingZeroes, (int)numPaddingZeroes); exitCode = NOTOK; } diff --git a/planarity/c/graphLib/io/g6-read-iterator.c b/planarity/c/graphLib/io/g6-read-iterator.c index 5fd6bf4..0ef1f09 100644 --- a/planarity/c/graphLib/io/g6-read-iterator.c +++ b/planarity/c/graphLib/io/g6-read-iterator.c @@ -7,14 +7,19 @@ See the LICENSE.TXT file for licensing information. #include #include +#include "strOrFile.h" + #include "g6-read-iterator.h" +// For definition of zero-based IO flag +#include "graphIO.h" + /* Imported functions */ -extern int _g6_GetNumCharsForEncoding(int); -extern int _g6_GetNumCharsForOrder(int); -extern int _g6_GetExpectedNumPaddingZeroes(const int, const int); +extern size_t _g6_GetNumCharsForEncoding(int order); +extern int _g6_GetNumCharsForOrder(int order); +extern size_t _g6_GetExpectedNumPaddingZeroes(const int order, const size_t numChars); extern int _g6_ValidateOrderOfEncodedGraph(char *graphBuff, int order); -extern int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numChars); +extern int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const size_t numChars); /* Private function declarations (exported within system) */ int _g6_ReadGraphFromStrOrFile(graphP theGraph, strOrFileP *pInputContainer); @@ -32,13 +37,39 @@ int _g6_DecodeGraph(char *graphBuff, const int order, const int numChars, graphP int _g6_ReadGraphFromFile(graphP theGraph, char *pathToG6File); int _g6_ReadGraphFromString(graphP theGraph, char *g6EncodedString); +/******************************************************************** + Package private structure declaration for read iterator + ********************************************************************/ + typedef struct strOrFileStruct strOrFileStruct; + typedef strOrFileStruct *strOrFileP; + + struct G6ReadIteratorStruct + { + strOrFileP inputContainer; + int numGraphsRead; + + int order; + int numCharsForOrder; + size_t numCharsForGraphEncoding; + size_t currGraphBuffSize; + char *currGraphBuff; + + graphP currGraph; + + bool endReached; + }; + +/******************************************************************** + Public and package private method implementations for read iterator + ********************************************************************/ + int g6_NewReader(G6ReadIteratorP *pG6ReadIterator, graphP theGraph) { int exitCode = OK; if (pG6ReadIterator == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to allocate G6ReadIterator, as pointer to which to assign " "address of memory allocated for G6ReadIterator is NULL.\n"); return NOTOK; @@ -46,18 +77,18 @@ int g6_NewReader(G6ReadIteratorP *pG6ReadIterator, graphP theGraph) if (pG6ReadIterator != NULL && (*pG6ReadIterator) != NULL) { - ErrorMessage( + gp_ErrorMessage( "G6ReadIterator is not NULL and therefore can't be allocated.\n"); return NOTOK; } // numGraphsRead, order, numCharsForOrder, // numCharsForGraphEncoding, and currGraphBuffSize all set to 0 - (*pG6ReadIterator) = (G6ReadIteratorP)calloc(1, sizeof(G6ReadIterator)); + (*pG6ReadIterator) = (G6ReadIteratorP)calloc(1, sizeof(G6ReadIteratorStruct)); if ((*pG6ReadIterator) == NULL) { - ErrorMessage("Unable to allocate memory for G6ReadIterator.\n"); + gp_ErrorMessage("Unable to allocate memory for G6ReadIterator.\n"); return NOTOK; } @@ -65,7 +96,7 @@ int g6_NewReader(G6ReadIteratorP *pG6ReadIterator, graphP theGraph) if (theGraph == NULL) { - ErrorMessage("Must allocate graph to be used by G6ReadIterator.\n"); + gp_ErrorMessage("Must allocate graph to be used by G6ReadIterator.\n"); g6_FreeReader(pG6ReadIterator); } @@ -84,7 +115,7 @@ bool _g6_IsReaderInitialized(G6ReadIteratorP theG6ReadIterator, bool reportUnini if (theG6ReadIterator == NULL) { if (reportUninitializedParts) - ErrorMessage("G6ReadIterator is NULL.\n"); + gp_ErrorMessage("G6ReadIterator is NULL.\n"); readerInitialized = false; } else @@ -92,20 +123,20 @@ bool _g6_IsReaderInitialized(G6ReadIteratorP theG6ReadIterator, bool reportUnini if (!sf_IsValidStrOrFile(theG6ReadIterator->inputContainer)) { if (reportUninitializedParts) - ErrorMessage("G6ReadIterator's inputContainer string-or-file container " - "is not valid.\n"); + gp_ErrorMessage("G6ReadIterator's inputContainer string-or-file container " + "is not valid.\n"); readerInitialized = false; } if (theG6ReadIterator->currGraphBuff == NULL) { if (reportUninitializedParts) - ErrorMessage("G6ReadIterator's currGraphBuff is NULL.\n"); + gp_ErrorMessage("G6ReadIterator's currGraphBuff is NULL.\n"); readerInitialized = false; } if (theG6ReadIterator->currGraph == NULL) { if (reportUninitializedParts) - ErrorMessage("G6ReadIterator's currGraph is NULL.\n"); + gp_ErrorMessage("G6ReadIterator's currGraph is NULL.\n"); readerInitialized = false; } } @@ -125,13 +156,13 @@ int g6_GetNumGraphsRead(G6ReadIteratorP theG6ReadIterator, int *pNumGraphsRead) { if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (pNumGraphsRead == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get numGraphsRead from G6ReadIterator, as output " "parameter pNumGraphsRead is NULL.\n"); return NOTOK; @@ -139,8 +170,8 @@ int g6_GetNumGraphsRead(G6ReadIteratorP theG6ReadIterator, int *pNumGraphsRead) if (!_g6_IsReaderInitialized(theG6ReadIterator, true)) { - ErrorMessage("Unable to get numGraphsRead, as G6ReadIterator is not " - "initialized.\n"); + gp_ErrorMessage("Unable to get numGraphsRead, as G6ReadIterator is not " + "initialized.\n"); (*pNumGraphsRead) = 0; @@ -156,13 +187,13 @@ int g6_GetOrderFromReader(G6ReadIteratorP theG6ReadIterator, int *pOrder) { if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (pOrder == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get order from G6ReadIterator, as output parameter " "pOrder is NULL.\n"); return NOTOK; @@ -170,8 +201,8 @@ int g6_GetOrderFromReader(G6ReadIteratorP theG6ReadIterator, int *pOrder) if (!_g6_IsReaderInitialized(theG6ReadIterator, true)) { - ErrorMessage("Unable to get order, as G6ReadIterator is not " - "initialized.\n"); + gp_ErrorMessage("Unable to get order, as G6ReadIterator is not " + "initialized.\n"); (*pOrder) = 0; @@ -187,13 +218,13 @@ int g6_GetGraphFromReader(G6ReadIteratorP theG6ReadIterator, graphP *pGraph) { if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (pGraph == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get graph from G6ReadIterator, as output parameter " "pGraph is NULL.\n"); return NOTOK; @@ -201,7 +232,7 @@ int g6_GetGraphFromReader(G6ReadIteratorP theG6ReadIterator, graphP *pGraph) if (!_g6_IsReaderInitialized(theG6ReadIterator, true)) { - ErrorMessage( + gp_ErrorMessage( "Unable to get graph from reader, as G6ReadIterator is not " "initialized.\n"); @@ -221,13 +252,13 @@ int g6_InitReaderWithString(G6ReadIteratorP theG6ReadIterator, char *inputString if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (_g6_IsReaderInitialized(theG6ReadIterator, false)) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize reader, as it was already previously " "initialized.\n"); return NOTOK; @@ -235,13 +266,13 @@ int g6_InitReaderWithString(G6ReadIteratorP theG6ReadIterator, char *inputString if (inputString == NULL || strlen(inputString) == 0) { - ErrorMessage("Unable to initialize reader with empty input string.\n"); + gp_ErrorMessage("Unable to initialize reader with empty input string.\n"); return NOTOK; } if ((inputContainer = sf_NewInputContainer(inputString, NULL)) == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize reader with string, as we failed to allocate " "the inputContainer.\n"); return NOTOK; @@ -258,13 +289,13 @@ int g6_InitReaderWithFileName(G6ReadIteratorP theG6ReadIterator, char const *con if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (_g6_IsReaderInitialized(theG6ReadIterator, false)) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize reader, as it was already previously " "initialized.\n"); return NOTOK; @@ -272,13 +303,13 @@ int g6_InitReaderWithFileName(G6ReadIteratorP theG6ReadIterator, char const *con if (infileName == NULL || strlen(infileName) == 0) { - ErrorMessage("Unable to initialize reader with empty infile name.\n"); + gp_ErrorMessage("Unable to initialize reader with empty infile name.\n"); return NOTOK; } if ((inputContainer = sf_NewInputContainer(NULL, infileName)) == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize reader with filename, as we failed to " "allocate the inputContainer.\n"); return NOTOK; @@ -293,14 +324,14 @@ int _g6_InitReaderWithStrOrFile(G6ReadIteratorP theG6ReadIterator, strOrFileP *p { if (theG6ReadIterator == NULL) { - ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6ReadIterator must be non-NULL.\n"); return NOTOK; } if (pInputContainer == NULL || !sf_IsValidStrOrFile((*pInputContainer))) { - ErrorMessage("Unable to initialize reader with invalid strOrFile " - "input container.\n"); + gp_ErrorMessage("Unable to initialize reader with invalid strOrFile " + "input container.\n"); return NOTOK; } @@ -320,12 +351,10 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) int lineNum = 1; int order = NIL; strOrFileP inputContainer = theG6ReadIterator->inputContainer; - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; if ((firstChar = sf_getc(inputContainer)) == EOF) { - ErrorMessage("Unable to initialize reader: .g6 infile is empty.\n"); + gp_ErrorMessage("Unable to initialize reader: .g6 infile is empty.\n"); return NOTOK; } else @@ -334,8 +363,8 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) if (charConfirmation != firstChar) { - ErrorMessage("Unable to initialize reader due to failure to ungetc " - "first character.\n"); + gp_ErrorMessage("Unable to initialize reader due to failure to ungetc " + "first character.\n"); return NOTOK; } @@ -343,8 +372,8 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) { if (_g6_ValidateHeader(inputContainer) != OK) { - ErrorMessage("Unable to initialize reader due to inability to " - "process and check .g6 infile header.\n"); + gp_ErrorMessage("Unable to initialize reader due to inability to " + "process and check .g6 infile header.\n"); return NOTOK; } } @@ -355,8 +384,8 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) if (charConfirmation != firstChar) { - ErrorMessage("Unable to initialize reader due to failure to ungetc " - "first character.\n"); + gp_ErrorMessage("Unable to initialize reader due to failure to ungetc " + "first character.\n"); return NOTOK; } @@ -367,8 +396,9 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) // in practice n will be limited such that an integer will suffice in storing it. if (_g6_DetermineOrderFromInput(inputContainer, &order) != OK) { - sprintf(messageContents, "Unable to initialize reader due to invalid graph order on line %d of .g6 file.\n", lineNum); - ErrorMessage(messageContents); + gp_ErrorMessage("Unable to initialize reader due to invalid graph order " + "on line %d of .g6 file.\n", + lineNum); return NOTOK; } @@ -376,8 +406,10 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) { if (gp_InitGraph(theG6ReadIterator->currGraph, order) != OK) { - sprintf(messageContents, "Unable to initialize reader due to failure initializing graph datastructure with order %d for graph on line %d of the .g6 file.\n", order, lineNum); - ErrorMessage(messageContents); + gp_ErrorMessage("Unable to initialize reader due to failure " + "initializing graph datastructure with order %d for " + "graph on line %d of the .g6 file.\n", + order, lineNum); return NOTOK; } @@ -387,23 +419,22 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) { if (gp_GetN(theG6ReadIterator->currGraph) != order) { - ErrorMessage("Unable to initialize reader, as graph datastructure " - "passed in was already initialized "); - sprintf(messageContents, "with graph order %d,\n", gp_GetN(theG6ReadIterator->currGraph)); - ErrorMessage(messageContents); - sprintf(messageContents, "\twhich doesn't match the graph order %d specified in the file.\n", order); - ErrorMessage(messageContents); + gp_ErrorMessage("Unable to initialize reader, as graph datastructure " + "passed in was already initialized with graph order " + "%d,\n\twhich doesn't match the graph order %d " + "specified in the file.\n", + gp_GetN(theG6ReadIterator->currGraph), order); return NOTOK; } else { - gp_ReinitializeGraph(theG6ReadIterator->currGraph); + gp_ReinitGraph(theG6ReadIterator->currGraph); theG6ReadIterator->order = order; } } // Ensures zero-based flag is set regardless of whether the graph was initialized or reinitialized. - theG6ReadIterator->currGraph->graphFlags |= FLAGS_ZEROBASEDIO; + theG6ReadIterator->currGraph->graphFlags |= GRAPHFLAGS_ZEROBASEDIO; theG6ReadIterator->numCharsForOrder = _g6_GetNumCharsForOrder(order); theG6ReadIterator->numCharsForGraphEncoding = _g6_GetNumCharsForEncoding(order); @@ -413,7 +444,7 @@ int _g6_InitReader(G6ReadIteratorP theG6ReadIterator) if (theG6ReadIterator->currGraphBuff == NULL) { - ErrorMessage("Unable to allocate memory for currGraphBuff.\n"); + gp_ErrorMessage("Unable to allocate memory for currGraphBuff.\n"); return NOTOK; } @@ -431,7 +462,7 @@ int _g6_ValidateHeader(strOrFileP inputContainer) if (inputContainer == NULL) { - ErrorMessage("Invalid .g6 string-or-file container.\n"); + gp_ErrorMessage("Invalid .g6 string-or-file container.\n"); return NOTOK; } @@ -445,11 +476,11 @@ int _g6_ValidateHeader(strOrFileP inputContainer) if (strcmp(g6Header, headerCandidateChars) != 0) { if (strcmp(sparse6Header, headerCandidateChars) == 0) - ErrorMessage("Graph file is sparse6 format, which is not supported.\n"); + gp_ErrorMessage("Graph file is sparse6 format, which is not supported.\n"); else if (strcmp(digraph6Header, headerCandidateChars) == 0) - ErrorMessage("Graph file is digraph6 format, which is not supported.\n"); + gp_ErrorMessage("Graph file is digraph6 format, which is not supported.\n"); else - ErrorMessage("Invalid header for .g6 file.\n"); + gp_ErrorMessage("Invalid header for .g6 file.\n"); return NOTOK; } @@ -461,9 +492,9 @@ int _g6_ValidateFirstChar(char c, const int lineNum) { if (strchr(":;&", c) != NULL) { - char messageContents[MAXLINE + 1]; - sprintf(messageContents, "Invalid first character on line %d, i.e. one of ':', ';', or '&'; aborting.\n", lineNum); - ErrorMessage(messageContents); + gp_ErrorMessage("Invalid first character on line %d, i.e. one of ':', " + "';', or '&'; aborting.\n", + lineNum); return NOTOK; } @@ -478,7 +509,7 @@ int _g6_DetermineOrderFromInput(strOrFileP inputContainer, int *order) if (inputContainer == NULL) { - ErrorMessage("Invalid string-or-file container for .g6 input.\n"); + gp_ErrorMessage("Invalid string-or-file container for .g6 input.\n"); return NOTOK; } @@ -489,9 +520,8 @@ int _g6_DetermineOrderFromInput(strOrFileP inputContainer, int *order) { if ((graphChar = sf_getc(inputContainer)) == 126) { - ErrorMessage("Graph order is too large; format suggests that " - "258048 <= n <= 68719476735, but only n <= 100000 is " - "supported.\n"); + gp_ErrorMessage("Graphs of order n > 100000 are not supported at this " + "time.\n"); return NOTOK; } @@ -505,7 +535,7 @@ int _g6_DetermineOrderFromInput(strOrFileP inputContainer, int *order) if (n > 100000) { - ErrorMessage("Graph order is too large; we only support n <= 100000.\n"); + gp_ErrorMessage("Graph order greater than 100000 not supported.\n"); return NOTOK; } } @@ -513,8 +543,8 @@ int _g6_DetermineOrderFromInput(strOrFileP inputContainer, int *order) n = graphChar - 63; else { - ErrorMessage("Graph order is too small; character doesn't correspond " - "to a printable ASCII character.\n"); + gp_ErrorMessage("Graph order is too small; character doesn't correspond " + "to a printable ASCII character.\n"); return NOTOK; } @@ -535,12 +565,10 @@ int g6_ReadGraph(G6ReadIteratorP theG6ReadIterator) const int numCharsForOrder = theG6ReadIterator == NULL ? 0 : theG6ReadIterator->numCharsForOrder; const int numCharsForGraphEncoding = theG6ReadIterator == NULL ? 0 : theG6ReadIterator->numCharsForGraphEncoding; const int currGraphBuffSize = theG6ReadIterator == NULL ? 0 : theG6ReadIterator->currGraphBuffSize; - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; if (!_g6_IsReaderInitialized(theG6ReadIterator, true)) { - ErrorMessage("G6ReadIterator is not initialized.\n"); + gp_ErrorMessage("G6ReadIterator is not initialized.\n"); return NOTOK; } @@ -566,8 +594,8 @@ int g6_ReadGraph(G6ReadIteratorP theG6ReadIterator) // longer than the line should have been, i.e. orderOffset + numCharsForGraphRepr if ((int)strlen(currGraphBuff) != (((numGraphsRead == 1) ? 0 : numCharsForOrder) + numCharsForGraphEncoding)) { - sprintf(messageContents, "Invalid line length read on line %d\n", numGraphsRead); - ErrorMessage(messageContents); + gp_ErrorMessage("Invalid line length read on line %d\n", + numGraphsRead); return NOTOK; } @@ -575,8 +603,8 @@ int g6_ReadGraph(G6ReadIteratorP theG6ReadIterator) { if (_g6_ValidateOrderOfEncodedGraph(currGraphBuff, order) != OK) { - sprintf(messageContents, "Order of graph on line %d is incorrect.\n", numGraphsRead); - ErrorMessage(messageContents); + gp_ErrorMessage("Order of graph on line %d is incorrect.\n", + numGraphsRead); return NOTOK; } } @@ -589,22 +617,22 @@ int g6_ReadGraph(G6ReadIteratorP theG6ReadIterator) if (_g6_ValidateGraphEncoding(graphEncodingChars, order, numCharsForGraphEncoding) != OK) { - sprintf(messageContents, "Graph on line %d is invalid.", numGraphsRead); - ErrorMessage(messageContents); + gp_ErrorMessage("Graph on line %d is invalid.", numGraphsRead); return NOTOK; } if (numGraphsRead > 1) { - gp_ReinitializeGraph(currGraph); + gp_ReinitGraph(currGraph); // Ensures zero-based flag is set after reinitializing graph. - currGraph->graphFlags |= FLAGS_ZEROBASEDIO; + currGraph->graphFlags |= GRAPHFLAGS_ZEROBASEDIO; } if (_g6_DecodeGraph(graphEncodingChars, order, numCharsForGraphEncoding, currGraph) != OK) { - sprintf(messageContents, "Unable to interpret bits on line %d to populate adjacency matrix.\n", numGraphsRead); - ErrorMessage(messageContents); + gp_ErrorMessage("Unable to interpret bits on line %d to populate " + "adjacency matrix.\n", + numGraphsRead); return NOTOK; } @@ -612,7 +640,6 @@ int g6_ReadGraph(G6ReadIteratorP theG6ReadIterator) } else { - theG6ReadIterator->currGraph = NULL; theG6ReadIterator->endReached = true; } @@ -637,19 +664,20 @@ int _g6_DecodeGraph(char *graphBuff, const int order, const int numChars, graphP if (theGraph == NULL) { - ErrorMessage("Must initialize graph datastructure before decoding the graph representation.\n"); + gp_ErrorMessage("Must initialize graph datastructure before decoding the " + "graph representation.\n"); return NOTOK; } for (int i = 0; i < numChars; i++) { currByte = graphBuff[i] - 63; - // j corresponds to the number of places one must bitshift the byte by to read - // the next bit in the byte + // j corresponds to the number of places one must bitshift the byte by + // to read the next bit in the byte for (int j = sizeof(char) * 5; j >= 0; j--) { - // If we are on the final byte, we know that the final numPaddingZeroes bits - // can be ignored, so we break out of the loop + // If we are on the final byte, we know that the final + // numPaddingZeroes bits can be ignored, so we break out of the loop if ((i == numChars) && j == numPaddingZeroes - 1) break; @@ -662,8 +690,11 @@ int _g6_DecodeGraph(char *graphBuff, const int order, const int numChars, graphP bitValue = ((currByte >> j) & 1u) ? 1 : 0; if (bitValue == 1) { - // Add gp_GetFirstVertex(theGraph), which is 1 if NIL == 0 (i.e. internal 1-based labelling) and 0 if NIL == -1 (internally 0-based) - if (gp_DynamicAddEdge(theGraph, row + gp_GetFirstVertex(theGraph), 0, col + gp_GetFirstVertex(theGraph), 0) != OK) + // Also add the offset to the first vertex in in-memory storage, + // because the G6 file is 0-based, but im-memory storage may not be. + if (gp_DynamicAddEdge(theGraph, + row + gp_LowerBoundVertexStorage(theGraph), 0, + col + gp_LowerBoundVertexStorage(theGraph), 0) != OK) return NOTOK; } @@ -699,14 +730,11 @@ void g6_FreeReader(G6ReadIteratorP *pG6ReadIterator) int _g6_ReadGraphFromFile(graphP theGraph, char *pathToG6File) { - char const *messageFormat = NULL; - int charsAvailForStr = 0; - strOrFileP inputContainer = NULL; if (pathToG6File == NULL || strlen(pathToG6File) == 0) { - ErrorMessage( + gp_ErrorMessage( "Unable to read graph from file, as pathToG6File is NULL " "or empty string.\n"); return NOTOK; @@ -714,15 +742,9 @@ int _g6_ReadGraphFromFile(graphP theGraph, char *pathToG6File) if ((inputContainer = sf_NewInputContainer(NULL, pathToG6File)) == NULL) { - char messageContents[MAXLINE + 1]; - messageContents[0] = '\0'; - messageFormat = "Unable to allocate strOrFile container for infile \"%.*s\".\n"; - charsAvailForStr = (int)(MAXLINE - strlen(messageFormat)); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(messageContents, messageFormat, charsAvailForStr, pathToG6File); -#pragma GCC diagnostic pop - ErrorMessage(messageContents); + gp_ErrorMessage("Unable to allocate strOrFile container for infile " + "\"%.*s\".\n", + FILENAME_MAX, pathToG6File); return NOTOK; } @@ -736,13 +758,13 @@ int _g6_ReadGraphFromString(graphP theGraph, char *g6EncodedString) if (g6EncodedString == NULL || strlen(g6EncodedString) == 0) { - ErrorMessage("Unable to proceed with empty .g6 input string.\n"); + gp_ErrorMessage("Unable to proceed with empty .g6 input string.\n"); return NOTOK; } if ((inputContainer = sf_NewInputContainer(g6EncodedString, NULL)) == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to allocate strOrFile container for .g6 input string.\n"); return NOTOK; } @@ -756,13 +778,13 @@ int _g6_ReadGraphFromStrOrFile(graphP theGraph, strOrFileP *pInputContainer) if (!sf_IsValidStrOrFile((*pInputContainer))) { - ErrorMessage("Invalid G6 output container.\n"); + gp_ErrorMessage("Invalid G6 output container.\n"); return NOTOK; } if (g6_NewReader((&theG6ReadIterator), theGraph) != OK) { - ErrorMessage("Unable to allocate G6ReadIterator.\n"); + gp_ErrorMessage("Unable to allocate G6ReadIterator.\n"); return NOTOK; } @@ -770,7 +792,7 @@ int _g6_ReadGraphFromStrOrFile(graphP theGraph, strOrFileP *pInputContainer) // since the read iterator will take ownership of the input container. if (_g6_InitReaderWithStrOrFile(theG6ReadIterator, pInputContainer) != OK) { - ErrorMessage("Unable to initialize G6ReadIterator.\n"); + gp_ErrorMessage("Unable to initialize G6ReadIterator.\n"); g6_FreeReader((&theG6ReadIterator)); @@ -778,7 +800,7 @@ int _g6_ReadGraphFromStrOrFile(graphP theGraph, strOrFileP *pInputContainer) } if (g6_ReadGraph(theG6ReadIterator) != OK) - ErrorMessage("Unable to read graph from .g6 read iterator.\n"); + gp_ErrorMessage("Unable to read graph from .g6 read iterator.\n"); g6_FreeReader((&theG6ReadIterator)); diff --git a/planarity/c/graphLib/io/g6-read-iterator.h b/planarity/c/graphLib/io/g6-read-iterator.h index 991cdf1..135a148 100644 --- a/planarity/c/graphLib/io/g6-read-iterator.h +++ b/planarity/c/graphLib/io/g6-read-iterator.h @@ -16,24 +16,9 @@ extern "C" #include #include "../graph.h" -#include "strOrFile.h" - typedef struct - { - strOrFileP inputContainer; - int numGraphsRead; - - int order; - int numCharsForOrder; - int numCharsForGraphEncoding; - int currGraphBuffSize; - char *currGraphBuff; - - graphP currGraph; - - bool endReached; - } G6ReadIterator; - typedef G6ReadIterator *G6ReadIteratorP; + typedef struct G6ReadIteratorStruct G6ReadIteratorStruct; + typedef G6ReadIteratorStruct *G6ReadIteratorP; int g6_NewReader(G6ReadIteratorP *pG6ReadIterator, graphP theGraph); bool g6_EndReached(G6ReadIteratorP theG6ReadIterator); diff --git a/planarity/c/graphLib/io/g6-write-iterator.c b/planarity/c/graphLib/io/g6-write-iterator.c index 42c9d5b..2b156a0 100644 --- a/planarity/c/graphLib/io/g6-write-iterator.c +++ b/planarity/c/graphLib/io/g6-write-iterator.c @@ -7,13 +7,15 @@ See the LICENSE.TXT file for licensing information. #include #include +#include "strOrFile.h" + #include "g6-write-iterator.h" /* Imported functions */ -extern int _g6_GetNumCharsForEncoding(int); -extern int _g6_GetNumCharsForOrder(int); +extern size_t _g6_GetNumCharsForEncoding(int order); +extern int _g6_GetNumCharsForOrder(int order); extern int _g6_ValidateOrderOfEncodedGraph(char *graphBuff, int order); -extern int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const int numChars); +extern int _g6_ValidateGraphEncoding(char *graphBuff, const int order, const size_t numChars); /* Private function declarations (exported within system) */ int _g6_WriteGraphToStrOrFile(graphP theGraph, strOrFileP *pOutputContainer); @@ -22,7 +24,7 @@ int _g6_WriteGraphToStrOrFile(graphP theGraph, strOrFileP *pOutputContainer); int _g6_InitWriterWithStrOrFile(G6WriteIteratorP theG6WriteIterator, strOrFileP *pOutputContainer); int _g6_InitWriter(G6WriteIteratorP theG6WriteIterator); bool _g6_IsWriterInitialized(G6WriteIteratorP theG6WriteIterator, bool reportUninitializedParts); -void _g6_PrecomputeColumnOffsets(int *columnOffsets, int order); +void _g6_PrecomputeColumnOffsets(size_t *columnOffsets, int order); void _g6_EncodeAdjMatAsG6(G6WriteIteratorP theG6WriteIterator); void _g6_GetFirstEdgeInUse(graphP theGraph, int *e, int *u, int *v); void _g6_GetNextEdgeInUse(graphP theGraph, int *e, int *u, int *v); @@ -31,11 +33,37 @@ int _g6_WriteEncodedGraph(G6WriteIteratorP theG6WriteIterator); int _g6_WriteGraphToFile(graphP theGraph, char *g6OutputFileName); int _g6_WriteGraphToString(graphP theGraph, char **pOutputStr); +/******************************************************************** + Package private structure declaration for write iterator + ********************************************************************/ + typedef struct strOrFileStruct strOrFileStruct; + typedef strOrFileStruct *strOrFileP; + + struct G6WriteIteratorStruct + { + strOrFileP outputContainer; + int numGraphsWritten; + + int order; + int numCharsForOrder; + size_t numCharsForGraphEncoding; + size_t currGraphBuffSize; + char *currGraphBuff; + + size_t *columnOffsets; + + graphP currGraph; + }; + +/******************************************************************** + Public and package private method implementations for write iterator + ********************************************************************/ + int g6_NewWriter(G6WriteIteratorP *pG6WriteIterator, graphP theGraph) { if (pG6WriteIterator == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to allocate G6WriteIterator, as pointer to which to assign " "address of memory allocated for G6WriteIterator is NULL.\n"); return NOTOK; @@ -43,25 +71,25 @@ int g6_NewWriter(G6WriteIteratorP *pG6WriteIterator, graphP theGraph) if (pG6WriteIterator != NULL && (*pG6WriteIterator) != NULL) { - ErrorMessage("G6WriteIterator is not NULL and therefore can't be allocated.\n"); + gp_ErrorMessage("G6WriteIterator is not NULL and therefore can't be allocated.\n"); return NOTOK; } if (theGraph == NULL || gp_GetN(theGraph) <= 0) { - ErrorMessage("Must allocate and initialize graph with an order greater " - "than 0 to use the G6WriteIterator.\n"); + gp_ErrorMessage("Must allocate and initialize graph with an order greater " + "than 0 to use the G6WriteIterator.\n"); return NOTOK; } // numGraphsWritten, order, numCharsForOrder, // numCharsForGraphEncoding, and currGraphBuffSize all set to 0 - (*pG6WriteIterator) = (G6WriteIteratorP)calloc(1, sizeof(G6WriteIterator)); + (*pG6WriteIterator) = (G6WriteIteratorP)calloc(1, sizeof(G6WriteIteratorStruct)); if ((*pG6WriteIterator) == NULL) { - ErrorMessage("Unable to allocate memory for G6WriteIterator.\n"); + gp_ErrorMessage("Unable to allocate memory for G6WriteIterator.\n"); return NOTOK; } @@ -80,7 +108,7 @@ bool _g6_IsWriterInitialized(G6WriteIteratorP theG6WriteIterator, bool reportUni if (theG6WriteIterator == NULL) { if (reportUninitializedParts) - ErrorMessage("G6WriteIterator is NULL.\n"); + gp_ErrorMessage("G6WriteIterator is NULL.\n"); writerIsInitialized = false; } else @@ -88,25 +116,25 @@ bool _g6_IsWriterInitialized(G6WriteIteratorP theG6WriteIterator, bool reportUni if (!sf_IsValidStrOrFile(theG6WriteIterator->outputContainer)) { if (reportUninitializedParts) - ErrorMessage("G6WriteIterator's outputContainer is not valid.\n"); + gp_ErrorMessage("G6WriteIterator's outputContainer is not valid.\n"); writerIsInitialized = false; } if (theG6WriteIterator->currGraphBuff == NULL) { if (reportUninitializedParts) - ErrorMessage("G6WriteIterator's currGraphBuff is NULL.\n"); + gp_ErrorMessage("G6WriteIterator's currGraphBuff is NULL.\n"); writerIsInitialized = false; } if (theG6WriteIterator->columnOffsets == NULL) { if (reportUninitializedParts) - ErrorMessage("G6WriteIterator's columnOffsets is NULL.\n"); + gp_ErrorMessage("G6WriteIterator's columnOffsets is NULL.\n"); writerIsInitialized = false; } if (theG6WriteIterator->currGraph == NULL) { if (reportUninitializedParts) - ErrorMessage("G6WriteIterator's currGraph is NULL.\n"); + gp_ErrorMessage("G6WriteIterator's currGraph is NULL.\n"); writerIsInitialized = false; } else @@ -114,7 +142,7 @@ bool _g6_IsWriterInitialized(G6WriteIteratorP theG6WriteIterator, bool reportUni if (gp_GetN(theG6WriteIterator->currGraph) == 0) { if (reportUninitializedParts) - ErrorMessage( + gp_ErrorMessage( "G6WriteIterator's currGraph does not contain a valid " "graph.\n"); writerIsInitialized = false; @@ -129,13 +157,13 @@ int g6_GetNumGraphsWritten(G6WriteIteratorP theG6WriteIterator, int *pNumGraphsW { if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (pNumGraphsWritten == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get numGraphsWritten from G6WriteIterator, as output " "parameter pNumGraphsWritten is NULL.\n"); return NOTOK; @@ -143,8 +171,8 @@ int g6_GetNumGraphsWritten(G6WriteIteratorP theG6WriteIterator, int *pNumGraphsW if (!_g6_IsWriterInitialized(theG6WriteIterator, true)) { - ErrorMessage("Unable to get numGraphsWritten, as G6WriteIterator is " - "not initialized.\n"); + gp_ErrorMessage("Unable to get numGraphsWritten, as G6WriteIterator is " + "not initialized.\n"); (*pNumGraphsWritten) = 0; @@ -160,13 +188,13 @@ int g6_GetOrderFromWriter(G6WriteIteratorP theG6WriteIterator, int *pOrder) { if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (pOrder == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get order from G6WriteIterator, as output parameter " "pOrder is NULL.\n"); return NOTOK; @@ -174,8 +202,8 @@ int g6_GetOrderFromWriter(G6WriteIteratorP theG6WriteIterator, int *pOrder) if (!_g6_IsWriterInitialized(theG6WriteIterator, true)) { - ErrorMessage("Unable to get order, as G6WriteIterator is not " - "initialized.\n"); + gp_ErrorMessage("Unable to get order, as G6WriteIterator is not " + "initialized.\n"); (*pOrder) = 0; @@ -191,13 +219,13 @@ int g6_GetGraphFromWriter(G6WriteIteratorP theG6WriteIterator, graphP *pGraph) { if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (pGraph == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to get graph from G6WriteIterator, as output parameter " "pGraph is NULL.\n"); return NOTOK; @@ -205,8 +233,8 @@ int g6_GetGraphFromWriter(G6WriteIteratorP theG6WriteIterator, graphP *pGraph) if (!_g6_IsWriterInitialized(theG6WriteIterator, true)) { - ErrorMessage("Unable to get numGraphsWritten, as G6WriteIterator is " - "not initialized.\n"); + gp_ErrorMessage("Unable to get numGraphsWritten, as G6WriteIterator is " + "not initialized.\n"); (*pGraph) = NULL; @@ -224,13 +252,13 @@ int g6_InitWriterWithString(G6WriteIteratorP theG6WriteIterator, char **pOutputS if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (_g6_IsWriterInitialized(theG6WriteIterator, false)) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer, as it was already previously " "initialized.\n"); return NOTOK; @@ -238,7 +266,7 @@ int g6_InitWriterWithString(G6WriteIteratorP theG6WriteIterator, char **pOutputS if (pOutputString == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer with string, as pointer to which to " "assign address of output string is NULL.\n"); return NOTOK; @@ -246,7 +274,7 @@ int g6_InitWriterWithString(G6WriteIteratorP theG6WriteIterator, char **pOutputS if ((*pOutputString) != NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer with string, as pointer to which to " "assign address of output string points to allocated memory.\n"); return NOTOK; @@ -254,7 +282,7 @@ int g6_InitWriterWithString(G6WriteIteratorP theG6WriteIterator, char **pOutputS if ((outputContainer = sf_NewOutputContainer(pOutputString, NULL)) == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer with string, as we failed to allocate " "the outputContainer.\n"); return NOTOK; @@ -271,13 +299,13 @@ int g6_InitWriterWithFileName(G6WriteIteratorP theG6WriteIterator, char *outputF if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (_g6_IsWriterInitialized(theG6WriteIterator, false)) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer, as it was already previously " "initialized.\n"); return NOTOK; @@ -285,7 +313,7 @@ int g6_InitWriterWithFileName(G6WriteIteratorP theG6WriteIterator, char *outputF if (outputFileName == NULL || strlen(outputFileName) == 0) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer with NULL or empty output file " "name.\n"); return NOTOK; @@ -293,7 +321,7 @@ int g6_InitWriterWithFileName(G6WriteIteratorP theG6WriteIterator, char *outputF if ((outputContainer = sf_NewOutputContainer(NULL, outputFileName)) == NULL) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer with filename, as we failed to " "allocate the outputContainer.\n"); return NOTOK; @@ -308,13 +336,13 @@ int _g6_InitWriterWithStrOrFile(G6WriteIteratorP theG6WriteIterator, strOrFileP { if (theG6WriteIterator == NULL) { - ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); + gp_ErrorMessage("Invalid parameter: theG6WriteIterator must be non-NULL.\n"); return NOTOK; } if (_g6_IsWriterInitialized(theG6WriteIterator, false)) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer, as it was already previously " "initialized.\n"); return NOTOK; @@ -322,8 +350,8 @@ int _g6_InitWriterWithStrOrFile(G6WriteIteratorP theG6WriteIterator, strOrFileP if (!sf_IsValidStrOrFile((*pOutputContainer))) { - ErrorMessage("Unable to initialize writer with invalid strOrFile " - "output container.\n"); + gp_ErrorMessage("Unable to initialize writer with invalid strOrFile " + "output container.\n"); return NOTOK; } @@ -340,22 +368,29 @@ int _g6_InitWriter(G6WriteIteratorP theG6WriteIterator) { char const *g6Header = ">>graph6<<"; + theG6WriteIterator->order = gp_GetN(theG6WriteIterator->currGraph); + + if (theG6WriteIterator->order > 100000) + { + gp_ErrorMessage("Graphs of order n > 100000 are not supported at this " + "time.\n"); + return NOTOK; + } + if (sf_fputs(g6Header, theG6WriteIterator->outputContainer) < 0) { - ErrorMessage( + gp_ErrorMessage( "Unable to initialize writer due to failure to fputs header to " "outputContainer.\n"); return NOTOK; } - theG6WriteIterator->order = gp_GetN(theG6WriteIterator->currGraph); - - theG6WriteIterator->columnOffsets = (int *)calloc(theG6WriteIterator->order + 1, sizeof(int)); + theG6WriteIterator->columnOffsets = (size_t *)calloc(theG6WriteIterator->order + 1, sizeof(size_t)); if (theG6WriteIterator->columnOffsets == NULL) { - ErrorMessage("Unable to initialize writer due to failure to allocate " - "memory for column offsets.\n"); + gp_ErrorMessage("Unable to initialize writer due to failure to allocate " + "memory for column offsets.\n"); return NOTOK; } @@ -370,19 +405,24 @@ int _g6_InitWriter(G6WriteIteratorP theG6WriteIterator) if (theG6WriteIterator->currGraphBuff == NULL) { - ErrorMessage("Unable to initialize writer due to failure to allocate " - "memory for currGraphBuff.\n"); + gp_ErrorMessage("Unable to initialize writer due to failure to allocate " + "memory for currGraphBuff.\n"); return NOTOK; } return OK; } -void _g6_PrecomputeColumnOffsets(int *columnOffsets, int order) +/* + * NOTE: columnOffsets is an array of size_t rather than of int, because for a + * graph with N <= 100000, the index for an edge can be as large as + * (100000 * 99999) / 2, which overflows the size of a signed integer. + */ +void _g6_PrecomputeColumnOffsets(size_t *columnOffsets, int order) { if (columnOffsets == NULL) { - ErrorMessage("Must allocate columnOffsets memory before precomputation.\n"); + gp_ErrorMessage("Must allocate columnOffsets memory before precomputation.\n"); return; } @@ -397,7 +437,7 @@ int g6_WriteGraph(G6WriteIteratorP theG6WriteIterator) char *graphEncodingChars = NULL; if (!_g6_IsWriterInitialized(theG6WriteIterator, true)) { - ErrorMessage("Unable to write graph because G6WriteIterator is not initialized.\n"); + gp_ErrorMessage("Unable to write graph because G6WriteIterator is not initialized.\n"); return NOTOK; } @@ -405,20 +445,20 @@ int g6_WriteGraph(G6WriteIteratorP theG6WriteIterator) if (_g6_ValidateOrderOfEncodedGraph(theG6WriteIterator->currGraphBuff, theG6WriteIterator->order) != OK) { - ErrorMessage("Unable to write graph, as constructed encoding has incorrect order.\n"); + gp_ErrorMessage("Unable to write graph, as constructed encoding has incorrect order.\n"); return NOTOK; } graphEncodingChars = theG6WriteIterator->currGraphBuff + theG6WriteIterator->numCharsForOrder; if (_g6_ValidateGraphEncoding(graphEncodingChars, theG6WriteIterator->order, theG6WriteIterator->numCharsForGraphEncoding) != OK) { - ErrorMessage("Unable to write graph, as constructed encoding is invalid.\n"); + gp_ErrorMessage("Unable to write graph, as constructed encoding is invalid.\n"); return NOTOK; } if (_g6_WriteEncodedGraph(theG6WriteIterator) != OK) { - ErrorMessage("Unable to write g6 encoded graph to output container.\n"); + gp_ErrorMessage("Unable to write g6 encoded graph to output container.\n"); return NOTOK; } @@ -428,17 +468,18 @@ int g6_WriteGraph(G6WriteIteratorP theG6WriteIterator) void _g6_EncodeAdjMatAsG6(G6WriteIteratorP theG6WriteIterator) { char *g6Encoding = NULL; - int *columnOffsets = NULL; + size_t *columnOffsets = NULL; graphP theGraph = NULL; int order = 0; int numCharsForOrder = 0; - int numCharsForGraphEncoding = 0; - int totalNumCharsForOrderAndGraph = 0; + size_t numCharsForGraphEncoding = 0; + size_t totalNumCharsForOrderAndGraph = 0; int u = NIL, v = NIL, e = NIL; - int charOffset = 0; + size_t charOffset = 0; int bitPositionPower = 0; + int bitPosition = 0; g6Encoding = theG6WriteIterator->currGraphBuff; columnOffsets = theG6WriteIterator->columnOffsets; @@ -477,11 +518,10 @@ void _g6_EncodeAdjMatAsG6(G6WriteIteratorP theG6WriteIterator) charOffset = bitPositionPower = 0; while (u != NIL && v != NIL) { - // The internal graph representation is usually 1-based, but may be 0-based, so - // one must subtract the index of the first vertex (i.e. result of gp_GetFirstVertex) - // because the .g6 format is 0-based - u -= gp_GetFirstVertex(theGraph); - v -= gp_GetFirstVertex(theGraph); + // The in-memory vertex storage may 1-based or 0-based, so we subtract the index + // of the first vertex in storage because the .g6 format is 0-based + u -= gp_LowerBoundVertexStorage(theGraph); + v -= gp_LowerBoundVertexStorage(theGraph); // The columnOffset machinery assumes that we are traversing the edges represented in // the upper-triangular matrix. Since we are dealing with simple graphs, if (v, u) @@ -500,10 +540,14 @@ void _g6_EncodeAdjMatAsG6(G6WriteIteratorP theG6WriteIterator) // bit to set in that byte by left-shifting 1 by (5 - ((columnOffsets[v] + u) % 6)) // (transforming the ((columnOffsets[v] + u) % 6)th bit from the left to the // (5 - ((columnOffsets[v] + u) % 6))th bit from the right) + // NOTE: We've made columnOffsets an array of size_t because as N approaches + // 100000, the size of this calculation can exceed the limit of a signed + // integer charOffset = numCharsForOrder + ((columnOffsets[v] + u) / 6); bitPositionPower = 5 - ((columnOffsets[v] + u) % 6); - g6Encoding[charOffset] |= (1u << bitPositionPower); + bitPosition = (1u << bitPositionPower); + g6Encoding[charOffset] |= bitPosition; _g6_GetNextEdgeInUse(theGraph, &e, &u, &v); } @@ -511,7 +555,7 @@ void _g6_EncodeAdjMatAsG6(G6WriteIteratorP theG6WriteIterator) // Bytes corresponding to graph order have already been modified to // correspond to printable ascii character (i.e. by adding 63); must // now do the same for bytes corresponding to edge lists - for (int i = numCharsForOrder; i < totalNumCharsForOrderAndGraph; i++) + for (size_t i = numCharsForOrder; i < totalNumCharsForOrderAndGraph; i++) g6Encoding[i] += 63; } @@ -524,26 +568,24 @@ void _g6_GetFirstEdgeInUse(graphP theGraph, int *e, int *u, int *v) void _g6_GetNextEdgeInUse(graphP theGraph, int *e, int *u, int *v) { - int EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - (*u) = NIL; (*v) = NIL; if ((*e) == NIL) - (*e) = gp_EdgeArrayStart(theGraph); + (*e) = gp_LowerBoundEdges(theGraph); else (*e) += 2; - if ((*e) < EsizeOccupied) + if ((*e) < gp_UpperBoundEdges(theGraph)) { while (!gp_EdgeInUse(theGraph, (*e))) { (*e) += 2; - if ((*e) >= EsizeOccupied) + if ((*e) >= gp_UpperBoundEdges(theGraph)) break; } - if ((*e) < EsizeOccupied && gp_EdgeInUse(theGraph, (*e))) + if ((*e) < gp_UpperBoundEdges(theGraph) && gp_EdgeInUse(theGraph, (*e))) { (*u) = gp_GetNeighbor(theGraph, (*e)); (*v) = gp_GetNeighbor(theGraph, gp_GetTwin(theGraph, (*e))); @@ -555,13 +597,13 @@ int _g6_WriteEncodedGraph(G6WriteIteratorP theG6WriteIterator) { if (sf_fputs(theG6WriteIterator->currGraphBuff, theG6WriteIterator->outputContainer) < 0) { - ErrorMessage("Failed to output all characters of g6 encoding.\n"); + gp_ErrorMessage("Failed to output all characters of g6 encoding.\n"); return NOTOK; } if (sf_fputs("\n", theG6WriteIterator->outputContainer) < 0) { - ErrorMessage("Failed to put line terminator after g6 encoding.\n"); + gp_ErrorMessage("Failed to put line terminator after g6 encoding.\n"); return NOTOK; } @@ -609,14 +651,14 @@ int _g6_WriteGraphToFile(graphP theGraph, char *g6OutputFileName) if (g6OutputFileName == NULL || strlen(g6OutputFileName) == 0) { - ErrorMessage( + gp_ErrorMessage( "Unable to write graph to file, as output filename supplied is " "NULL or empty.\n"); return NOTOK; } if ((outputContainer = sf_NewOutputContainer(NULL, g6OutputFileName)) == NULL) { - ErrorMessage("Unable to allocate outputContainer to which to write.\n"); + gp_ErrorMessage("Unable to allocate outputContainer to which to write.\n"); return NOTOK; } @@ -629,21 +671,21 @@ int _g6_WriteGraphToString(graphP theGraph, char **pOutputStr) if (pOutputStr == NULL) { - ErrorMessage("If writing G6 to string, must provide pointer-pointer " - "to allow _g6_WriteGraphToString() to assign the " - "address of the output string.\n"); + gp_ErrorMessage("If writing G6 to string, must provide pointer-pointer " + "to allow _g6_WriteGraphToString() to assign the " + "address of the output string.\n"); return NOTOK; } if ((*pOutputStr) != NULL) { - ErrorMessage("(*pOutputStr) should not point to allocated memory."); + gp_ErrorMessage("(*pOutputStr) should not point to allocated memory."); return NOTOK; } if ((outputContainer = sf_NewOutputContainer(pOutputStr, NULL)) == NULL) { - ErrorMessage("Unable to allocate outputContainer to which to write.\n"); + gp_ErrorMessage("Unable to allocate outputContainer to which to write.\n"); return NOTOK; } @@ -659,13 +701,13 @@ int _g6_WriteGraphToStrOrFile(graphP theGraph, strOrFileP *pOutputContainer) if (!sf_IsValidStrOrFile((*pOutputContainer))) { - ErrorMessage("Invalid G6 output container.\n"); + gp_ErrorMessage("Invalid G6 output container.\n"); return NOTOK; } if (g6_NewWriter((&theG6WriteIterator), theGraph) != OK) { - ErrorMessage("Unable to allocate G6WriteIterator.\n"); + gp_ErrorMessage("Unable to allocate G6WriteIterator.\n"); g6_FreeWriter((&theG6WriteIterator)); return NOTOK; } @@ -674,14 +716,14 @@ int _g6_WriteGraphToStrOrFile(graphP theGraph, strOrFileP *pOutputContainer) // since the write iterator will take ownership of the output container. if (_g6_InitWriterWithStrOrFile(theG6WriteIterator, pOutputContainer) != OK) { - ErrorMessage("Unable to initialize G6WriteIterator.\n"); + gp_ErrorMessage("Unable to initialize G6WriteIterator.\n"); g6_FreeWriter((&theG6WriteIterator)); return NOTOK; } if (g6_WriteGraph(theG6WriteIterator) != OK) { - ErrorMessage("Unable to write graph using G6WriteIterator.\n"); + gp_ErrorMessage("Unable to write graph using G6WriteIterator.\n"); g6_FreeWriter((&theG6WriteIterator)); return NOTOK; } diff --git a/planarity/c/graphLib/io/g6-write-iterator.h b/planarity/c/graphLib/io/g6-write-iterator.h index 69703d6..6b75875 100644 --- a/planarity/c/graphLib/io/g6-write-iterator.h +++ b/planarity/c/graphLib/io/g6-write-iterator.h @@ -16,25 +16,9 @@ extern "C" #include #include "../graph.h" -#include "strOrFile.h" - typedef struct - { - strOrFileP outputContainer; - int numGraphsWritten; - - int order; - int numCharsForOrder; - int numCharsForGraphEncoding; - int currGraphBuffSize; - char *currGraphBuff; - - int *columnOffsets; - - graphP currGraph; - } G6WriteIterator; - - typedef G6WriteIterator *G6WriteIteratorP; + typedef struct G6WriteIteratorStruct G6WriteIteratorStruct; + typedef G6WriteIteratorStruct *G6WriteIteratorP; int g6_NewWriter(G6WriteIteratorP *pG6WriteIterator, graphP theGraph); diff --git a/planarity/c/graphLib/io/graphIO.c b/planarity/c/graphLib/io/graphIO.c index 5c6d6b3..63bad7e 100644 --- a/planarity/c/graphLib/io/graphIO.c +++ b/planarity/c/graphLib/io/graphIO.c @@ -8,7 +8,18 @@ See the LICENSE.TXT file for licensing information. #include #include -#include "../graph.h" +#include "graphIO.h" + +#include "strOrFile.h" + +#include "../extensionSystem/graphExtensions.private.h" + +// To help with writing debug info +#include "../planarityRelated/graphPlanarity.private.h" +#include "../graphDFSUtils.h" + +// To help with graph construction +#include "../graph.private.h" /* Imported functions */ extern int _g6_ReadGraphFromStrOrFile(graphP theGraph, strOrFileP *pG6InputContainer); @@ -28,20 +39,6 @@ int _WriteAdjMatrix(graphP theGraph, strOrFileP outputContainer); int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer); int _WritePostprocess(graphP theGraph, char **pExtraData); -// These prototypes are defined if LOGGING is defined, but -// if LOGGING is not defined, then these declarations help -// to get rid of missingprototype warnings. -#ifndef LOGGING -void _LogLine(const char *Line); -void _Log(const char *Line); - -char *_MakeLogStr1(char *format, int); -char *_MakeLogStr2(char *format, int, int); -char *_MakeLogStr3(char *format, int, int, int); -char *_MakeLogStr4(char *format, int, int, int, int); -char *_MakeLogStr5(char *format, int, int, int, int, int); -#endif - /* Private functions */ char _GetEdgeTypeChar(graphP theGraph, int e); char _GetObstructionMarkChar(graphP theGraph, int v); @@ -53,7 +50,7 @@ char _GetObstructionMarkChar(graphP theGraph, int v); Though O(N^2) time is required, this routine is useful during reliability testing due to the wealth of graph generating software that uses this format for output. - Returns: OK, NOTOK on internal error, NONEMBEDDABLE if too many edges + Returns: OK, NOTOK on internal error ********************************************************************/ int _ReadAdjMatrix(graphP theGraph, strOrFileP inputContainer) @@ -78,10 +75,10 @@ int _ReadAdjMatrix(graphP theGraph, strOrFileP inputContainer) // Read an upper-triangular matrix row for each vertex // Note that for the last vertex, zero flags are read, per the upper triangular format - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { gp_SetIndex(theGraph, v, v); - for (w = v + 1; gp_VertexInRangeAscending(theGraph, w); w++) + for (w = v + 1; w < gp_UpperBoundVertices(theGraph); w++) { // Read each of v's w-neighbor flags if (sf_ReadSkipWhitespace(inputContainer) != OK) @@ -127,7 +124,7 @@ int _ReadAdjMatrix(graphP theGraph, strOrFileP inputContainer) This makes it easy to used edge directedness when appropriate but also seamlessly process the corresponding undirected graph. - Returns: OK on success, NONEMBEDDABLE if success except too many edges + Returns: OK on success, NOTOK on file content error (or internal error) ********************************************************************/ @@ -163,11 +160,11 @@ int _ReadAdjList(graphP theGraph, strOrFileP inputContainer) // Clear the visited members of the vertices so they can be used // during the adjacency list read operation - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) gp_SetVertexVisitedInfo(theGraph, v, NIL); // Do the adjacency list read operation for each vertex in order - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { // Read the vertex number if (sf_ReadSkipWhitespace(inputContainer) != OK) @@ -177,15 +174,15 @@ int _ReadAdjList(graphP theGraph, strOrFileP inputContainer) if (sf_ReadSkipWhitespace(inputContainer) != OK) return NOTOK; - if (indexValue == 0 && v == gp_GetFirstVertex(theGraph)) + if (indexValue == 0 && v == gp_LowerBoundVertexStorage(theGraph)) zeroBased = TRUE; // If we are reading a zero-based input file, then we have to add to the - // indexValue for v the amount returned by gp_GetFirstVertex(), - // which is 1 if this library was compiled with USE_FASTER_1BASEDARRAYS - // or 0 if this library was compiled with USE_0BASEDARRAYS + // indexValue for v the offset of the first vertex in storage, which is + // usually 1 (because we compile with USE_1BASEDARRAYS by default) but + // which may be 0 if this library was compiled with USE_0BASEDARRAYS. if (zeroBased) - indexValue += gp_GetFirstVertex(theGraph); + indexValue += gp_LowerBoundVertexStorage(theGraph); gp_SetIndex(theGraph, v, indexValue); @@ -242,19 +239,19 @@ int _ReadAdjList(graphP theGraph, strOrFileP inputContainer) return NOTOK; // If we are reading a zero-based input file, then we have to add to W - // the amount returned by gp_GetFirstVertex(), which is 1 if this library - // was compiled with USE_FASTER_1BASEDARRAYS or 0 if this library was - // compiled with USE_0BASEDARRAYS + // the offset of the first vertex in storage, which is usually 1 + // (because we compile with USE_1BASEDARRAYS by default) but which may + // be 0 if this library was compiled with USE_0BASEDARRAYS. if (zeroBased) - W += gp_GetFirstVertex(theGraph); + W += gp_LowerBoundVertexStorage(theGraph); // A value below the valid range indicates the adjacency list end // This was written before gp_IsNotVertex() existed - if (W < gp_GetFirstVertex(theGraph)) + if (W < gp_LowerBoundVertices(theGraph)) break; // A value above the valid range is an error - if (W > gp_GetLastVertex(theGraph)) + if (W >= gp_UpperBoundVertices(theGraph)) return NOTOK; // Loop edges are not supported @@ -333,7 +330,7 @@ int _ReadAdjList(graphP theGraph, strOrFileP inputContainer) } if (zeroBased) - theGraph->graphFlags |= FLAGS_ZEROBASEDIO; + theGraph->graphFlags |= GRAPHFLAGS_ZEROBASEDIO; return OK; } @@ -344,7 +341,7 @@ int _ReadAdjList(graphP theGraph, strOrFileP inputContainer) LEDA files use a one-based numbering system, which is converted to zero-based numbers if the graph reports starting at zero as the first vertex. - Returns: OK on success, NONEMBEDDABLE if success except too many edges + Returns: OK on success, NOTOK on file content error (or internal error) ********************************************************************/ @@ -354,7 +351,7 @@ int _ReadLEDAGraph(graphP theGraph, strOrFileP inputContainer) int graphType = 0; int N = 0, M = 0, u = NIL, v = NIL; - int zeroBasedOffset = gp_GetFirstVertex(theGraph) == 0 ? 1 : 0; + int zeroBasedOffset = gp_LowerBoundVertexStorage(theGraph) == 0 ? 1 : 0; char Line[MAXLINE + 1]; memset(Line, '\0', (MAXLINE + 1)); @@ -392,7 +389,7 @@ int _ReadLEDAGraph(graphP theGraph, strOrFileP inputContainer) if (gp_InitGraph(theGraph, N) != OK) return NOTOK; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (sf_fgets(Line, MAXLINE, inputContainer) == NULL) return NOTOK; @@ -426,7 +423,7 @@ int _ReadLEDAGraph(graphP theGraph, strOrFileP inputContainer) } if (zeroBasedOffset) - theGraph->graphFlags |= FLAGS_ZEROBASEDIO; + theGraph->graphFlags |= GRAPHFLAGS_ZEROBASEDIO; return OK; } @@ -439,7 +436,7 @@ int _ReadLEDAGraph(graphP theGraph, strOrFileP inputContainer) Pass "stdin" for the FileName to read from the stdin stream. - Returns: OK, NOTOK on internal error, NONEMBEDDABLE if too many edges + Returns: OK, NOTOK on internal error ********************************************************************/ int gp_Read(graphP theGraph, char const *FileName) @@ -547,9 +544,8 @@ int _ReadGraph(graphP theGraph, strOrFileP *pInputContainer) // The possibility of "extra data" is not allowed for .g6 format: // .g6 files may contain multiple graphs, which are not valid input // for the extra data readers (i.e. fpReadPostProcess) Additionally, - // we don't want to add extra data if the graph is nonembeddable, as - // the FILE pointer isn't necessarily advanced past the graph - // encoding unless OK is returned. + // we don't want to process extra data unless the graph reading + // was OK. if (extraDataAllowed) { char charAfterGraphRead = EOF; @@ -574,7 +570,7 @@ int _ReadGraph(graphP theGraph, strOrFileP *pInputContainer) } if (sb_GetSize(extraData) > 0) - RetVal = theGraph->functions.fpReadPostprocess(theGraph, sb_GetReadString(extraData)); + RetVal = theGraph->functions->fpReadPostprocess(theGraph, sb_GetReadString(extraData)); sb_Free(&extraData); extraData = NULL; @@ -626,18 +622,18 @@ int _WriteAdjList(graphP theGraph, strOrFileP outputContainer) // If we are supposed to write 0-based output, then we have to adjust the vertex offset and the // adjacency list terminator based on whether this library has been compiled with 0-based or // 1-based array indexing for the in-memory data structure (i.e., compiled with - // USE_FASTER_1BASEDARRAYS USE_0BASEDARRAYS). The macro invoked is responsive to the difference. - if (gp_GetGraphFlags(theGraph) & FLAGS_ZEROBASEDIO) + // USE_1BASEDARRAYS USE_0BASEDARRAYS). The macro invoked is responsive to the difference. + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_ZEROBASEDIO) { - zeroBasedVertexOffset = gp_GetFirstVertex(theGraph); + zeroBasedVertexOffset = gp_LowerBoundVertexStorage(theGraph); // If the graph must be written 0-based, then the adjacency list terminator must be -1, - // even if the internal representation is 1-based (i.e. when USE_FASTER_1BASEDARRAYS, NIL == 0, + // even if the internal representation is 1-based (i.e. when USE_1BASEDARRAYS, NIL == 0, // but the output needs to be -1 for 0-based output) adjacencyListTerminator = -1; } // Write the adjacency list of each vertex - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (sprintf(numberStr, "%d:", v - zeroBasedVertexOffset) < 1) return NOTOK; @@ -703,13 +699,13 @@ int _WriteAdjMatrix(graphP theGraph, strOrFileP outputContainer) return NOTOK; // Construct the upper triangular matrix representation one row at a time - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { - for (int i = gp_GetFirstVertex(theGraph); i <= v; i++) - Row[i - gp_GetFirstVertex(theGraph)] = ' '; + for (int i = gp_LowerBoundVertices(theGraph); i <= v; i++) + Row[i - gp_LowerBoundVertices(theGraph)] = ' '; - for (int i = v + 1; gp_VertexInRangeAscending(theGraph, i); i++) - Row[i - gp_GetFirstVertex(theGraph)] = '0'; + for (int i = v + 1; i < gp_UpperBoundVertices(theGraph); i++) + Row[i - gp_LowerBoundVertices(theGraph)] = '0'; e = gp_GetFirstEdge(theGraph, v); while (gp_IsEdge(theGraph, e)) @@ -718,7 +714,7 @@ int _WriteAdjMatrix(graphP theGraph, strOrFileP outputContainer) return NOTOK; if (gp_GetNeighbor(theGraph, e) > v) - Row[gp_GetNeighbor(theGraph, e) - gp_GetFirstVertex(theGraph)] = '1'; + Row[gp_GetNeighbor(theGraph, e) - gp_LowerBoundVertices(theGraph)] = '1'; e = gp_GetNextEdge(theGraph, e); } @@ -752,7 +748,7 @@ char _GetEdgeTypeChar(graphP theGraph, int e) type = 'P'; else if (gp_GetEdgeType(theGraph, e) == EDGE_TYPE_BACK) type = 'B'; - else if (gp_GetEdgeType(theGraph, e) == EDGE_TYPE_RANDOMTREE) + else if (gp_GetEdgeType(theGraph, e) == EDGE_TYPE_TREE) type = 'T'; return type; @@ -786,7 +782,7 @@ char _GetObstructionMarkChar(graphP theGraph, int v) int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) { - int v = NIL, e = NIL, EsizeOccupied = 0; + int v = NIL, e = NIL; char lineBuf[MAXLINE + 1]; memset(lineBuf, '\0', (MAXLINE + 1) * sizeof(char)); @@ -800,7 +796,7 @@ int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) if (sf_fputs(lineBuf, outputContainer) == EOF) return NOTOK; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (sprintf(lineBuf, "%d(P=%d,lA=%d,LowPt=%d,v=%d):", v, gp_GetVertexParent(theGraph, v), @@ -829,7 +825,7 @@ int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) /* Print any root copy vertices and their adjacency lists */ - for (v = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVirtualVertices(theGraph); v < gp_UpperBoundVirtualVertices(theGraph); ++v) { if (!gp_VirtualVertexInUse(theGraph, v)) continue; @@ -862,7 +858,7 @@ int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) if (sf_fputs("\nVERTEX INFORMATION\n", outputContainer) == EOF) return NOTOK; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (sprintf(lineBuf, "V[%3d] index=%3d, type=%c, first edge=%3d, last edge=%3d\n", v, @@ -874,7 +870,7 @@ int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) if (sf_fputs(lineBuf, outputContainer) == EOF) return NOTOK; } - for (v = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVirtualVertices(theGraph); v < gp_UpperBoundVirtualVertices(theGraph); ++v) { if (gp_VirtualVertexNotInUse(theGraph, v)) continue; @@ -895,8 +891,7 @@ int _WriteDebugInfo(graphP theGraph, strOrFileP outputContainer) if (sf_fputs("\nEDGE INFORMATION\n", outputContainer) == EOF) return NOTOK; - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e++) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); ++e) { if (gp_EdgeInUse(theGraph, e)) { @@ -1047,7 +1042,7 @@ int _WriteGraph(graphP theGraph, strOrFileP *pOutputContainer, int Mode) { char *extraData = NULL; - RetVal = theGraph->functions.fpWritePostprocess(theGraph, &extraData); + RetVal = theGraph->functions->fpWritePostprocess(theGraph, &extraData); if (extraData != NULL) { @@ -1072,84 +1067,3 @@ int _WritePostprocess(graphP theGraph, char **pExtraData) { return OK; } - -/******************************************************************** - _Log() - - When the project is compiled with LOGGING enabled, this method writes - a string to the file PLANARITY.LOG in the current working directory. - On first write, the file is created or cleared. - Call this method with NULL to close the log file. - ********************************************************************/ - -void _Log(char const *Str) -{ - static FILE *logfile = NULL; - - if (logfile == NULL) - { - if ((logfile = fopen("PLANARITY.LOG", WRITETEXT)) == NULL) - return; - } - - if (Str != NULL) - { - fprintf(logfile, "%s", Str); - fflush(logfile); - } - else - fclose(logfile); -} - -void _LogLine(char const *Str) -{ - _Log(Str); - _Log("\n"); -} - -static char LogStr[MAXLINE + 1]; - -char *_MakeLogStr1(char *format, int one) -{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(LogStr, format, one); -#pragma GCC diagnostic pop - return LogStr; -} - -char *_MakeLogStr2(char *format, int one, int two) -{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(LogStr, format, one, two); -#pragma GCC diagnostic pop - return LogStr; -} - -char *_MakeLogStr3(char *format, int one, int two, int three) -{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(LogStr, format, one, two, three); -#pragma GCC diagnostic pop - return LogStr; -} - -char *_MakeLogStr4(char *format, int one, int two, int three, int four) -{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(LogStr, format, one, two, three, four); -#pragma GCC diagnostic pop - return LogStr; -} - -char *_MakeLogStr5(char *format, int one, int two, int three, int four, int five) -{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" - sprintf(LogStr, format, one, two, three, four, five); -#pragma GCC diagnostic pop - return LogStr; -} diff --git a/planarity/c/graphLib/io/graphIO.h b/planarity/c/graphLib/io/graphIO.h new file mode 100644 index 0000000..6dfccc1 --- /dev/null +++ b/planarity/c/graphLib/io/graphIO.h @@ -0,0 +1,38 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHIO_H +#define GRAPHIO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "../graph.h" + + int gp_Read(graphP theGraph, char const *FileName); + int gp_ReadFromString(graphP theGraph, char *inputStr); + + int gp_Write(graphP theGraph, char const *FileName, int Mode); + int gp_WriteToString(graphP theGraph, char **pOutputStr, int Mode); + +// Mode values for gp_Write() and gp_WriteToString() +#define WRITE_ADJLIST 1 +#define WRITE_ADJMATRIX 2 +#define WRITE_DEBUGINFO 3 +#define WRITE_G6 4 + +// Graph Flags: see gp_GetGraphFlags() +// GRAPHFLAGS_ZEROBASEDIO is typically set by gp_Read() to indicate that the +// adjacency list representation in a file began with index 0. +#define GRAPHFLAGS_ZEROBASEDIO 16 + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHIO_H */ diff --git a/planarity/c/graphLib/io/strOrFile.c b/planarity/c/graphLib/io/strOrFile.c index 5edc1f8..8b32b82 100644 --- a/planarity/c/graphLib/io/strOrFile.c +++ b/planarity/c/graphLib/io/strOrFile.c @@ -37,7 +37,7 @@ strOrFileP sf_NewInputContainer(char const *const inputStr, char const *const fi ((fileName == NULL) && (inputStr == NULL))) return NULL; - theStrOrFile = (strOrFileP)calloc(1, sizeof(strOrFile)); + theStrOrFile = (strOrFileP)calloc(1, sizeof(strOrFileStruct)); if (theStrOrFile != NULL) { theStrOrFile->containerType = INPUT_CONTAINER; @@ -127,7 +127,7 @@ strOrFileP sf_NewOutputContainer(char **pOutputStr, char const *const fileName) ((pOutputStr != NULL) && ((*pOutputStr) != NULL))) return NULL; - theStrOrFile = (strOrFileP)calloc(1, sizeof(strOrFile)); + theStrOrFile = (strOrFileP)calloc(1, sizeof(strOrFileStruct)); if (theStrOrFile != NULL) { theStrOrFile->containerType = OUTPUT_CONTAINER; diff --git a/planarity/c/graphLib/io/strOrFile.h b/planarity/c/graphLib/io/strOrFile.h index 8fa7794..2dbcf47 100644 --- a/planarity/c/graphLib/io/strOrFile.h +++ b/planarity/c/graphLib/io/strOrFile.h @@ -20,16 +20,17 @@ extern "C" #define INPUT_CONTAINER 1 #define OUTPUT_CONTAINER 2 - typedef struct + struct strOrFileStruct { char **pOutputStr; strBufP theStrBuf; FILE *pFile; int containerType; stackP ungetBuf; - } strOrFile; + }; - typedef strOrFile *strOrFileP; + typedef struct strOrFileStruct strOrFileStruct; + typedef strOrFileStruct *strOrFileP; strOrFileP sf_NewInputContainer(char const *const inputStr, char const *const fileName); strOrFileP sf_NewOutputContainer(char **pOutputStr, char const *const fileName); diff --git a/planarity/c/graphLib/lowLevelUtils/apiutils.c b/planarity/c/graphLib/lowLevelUtils/apiutils.c index 44f329b..e1193b9 100644 --- a/planarity/c/graphLib/lowLevelUtils/apiutils.c +++ b/planarity/c/graphLib/lowLevelUtils/apiutils.c @@ -6,68 +6,181 @@ See the LICENSE.TXT file for licensing information. #include #include -#include #include -#include "apiutils.h" #include "appconst.h" -int quietMode = FALSE; +#include "apiutils.h" +#include "apiutils.private.h" + +// The graphLib gp_ErrorMessage() and gp_Message() calls are suppressed by +// default, but an application can turn them on if desired. +int quietModeFlag = TRUE; -int getQuietModeSetting(void) +int gp_GetQuietModeFlag(void) { - return quietMode; + return quietModeFlag; } -void setQuietModeSetting(int newQuietModeSetting) +void gp_SetQuietModeFlag(int newQuietModeFlag) { - quietMode = newQuietModeSetting; + quietModeFlag = newQuietModeFlag; } -void Message(char const *message) +void gp_Message(char const *message, ...) { - if (!getQuietModeSetting()) + va_list args; + if (!gp_GetQuietModeFlag()) { - fprintf(stdout, "%s", message); + va_start(args, message); + vfprintf(stdout, message, args); + va_end(args); fflush(stdout); } } -void ErrorMessage(char const *message) +void gp_ErrorMessage(char const *message, ...) { - if (!getQuietModeSetting()) + va_list args; + if (!gp_GetQuietModeFlag()) { - fprintf(stderr, "%s", message); + va_start(args, message); + vfprintf(stderr, message, args); + va_end(args); fflush(stderr); } } -int GetNumCharsToReprInt(int theNum, int *numCharsRequired) +/******************************************************************** + debugNOTOK() + + This function returns the literal value of NOTOK. In debug mode, + NOTOK is redefined to first use printf() to emit information about + where in the code a NOTOK has occurred. Then, this method is invoked + so that the debug version of NOTOK still returns the NOTOK value. + + Rather than just returning 0 in the debug-mode NOTOK macro, we + invoke this method because it gives the option (with recompilation) + of having the program exit on the first NOTOK occurrence. That + option is off by default, so we normally get a stack trace of the + NOTOK occcurences, but on an exhaustive, long-run test, it can be + handy to stop on the first error since otherwise the error message + might not be seen. + ********************************************************************/ + +#ifdef DEBUG +int debugNOTOK(void) { - int charCount = 0; + // exit(-1); + return 0; // NOTOK is normally defined to be zero +} +#endif + +// LOGGING is not defined in the standard compile configuration. +// A graphLib developer can uncomment LOGGING in apiutils.private.h +#ifdef LOGGING + +/******************************************************************** + _Log() - if (numCharsRequired == NULL) - return NOTOK; + When the project is compiled with LOGGING enabled, this method writes + a string to the file Edge_Addition_Planarity_Suite.LOG in the current + working directory. - if (theNum < 0) + On first write, the file is created or cleared. + Call this method with NULL to close the log file. + ********************************************************************/ + +void closeLogFileAtExit(void); + +void _Log(char const *Str) +{ + static FILE *logfile = NULL; + static int triedlogfile = FALSE; + + if (logfile == NULL && !triedlogfile) { - charCount++; - // N.B. since 32-bit signed integers are represented using twos-complement, - // the absolute value of INT_MIN is not defined; however, adding 1 to this - // min value before taking the absolute value will still require the same - // number of digits. - if ((theNum == INT_MIN) || (theNum == INT8_MAX) || (theNum == INT16_MIN) || (theNum == INT32_MIN)) - theNum++; - theNum = abs(theNum); + triedlogfile = TRUE; + if (atexit(closeLogFileAtExit) != 0) + gp_ErrorMessage("Unable to set up atexit() to close Edge_Addition_Planarity_Suite log file on exit"); + else + { + if ((logfile = fopen("Edge_Addition_Planarity_Suite.LOG", WRITETEXT)) == NULL) + gp_ErrorMessage("Unable to open the Edge_Addition_Planarity_Suite log file"); + } } - while (theNum > 0) + if (logfile != NULL) { - theNum /= 10; - charCount++; + if (Str != NULL) + { + fprintf(logfile, "%s", Str); + fflush(logfile); + } + else + { + fclose(logfile); + logfile = NULL; + } } +} + +void _LogLine(char const *Str) +{ + _Log(Str); + _Log("\n"); +} - (*numCharsRequired) = charCount; +void closeLogFileAtExit(void) +{ + _gp_Log(NULL); +} + +static char LogStr[MAXLINE + 1]; - return OK; +char *_MakeLogStr1(const char *format, int one) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + sprintf(LogStr, format, one); +#pragma GCC diagnostic pop + return LogStr; } + +char *_MakeLogStr2(const char *format, int one, int two) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + sprintf(LogStr, format, one, two); +#pragma GCC diagnostic pop + return LogStr; +} + +char *_MakeLogStr3(const char *format, int one, int two, int three) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + sprintf(LogStr, format, one, two, three); +#pragma GCC diagnostic pop + return LogStr; +} + +char *_MakeLogStr4(const char *format, int one, int two, int three, int four) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + sprintf(LogStr, format, one, two, three, four); +#pragma GCC diagnostic pop + return LogStr; +} + +char *_MakeLogStr5(const char *format, int one, int two, int three, int four, int five) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + sprintf(LogStr, format, one, two, three, four, five); +#pragma GCC diagnostic pop + return LogStr; +} + +#endif // LOGGING diff --git a/planarity/c/graphLib/lowLevelUtils/apiutils.h b/planarity/c/graphLib/lowLevelUtils/apiutils.h index c9abde6..8a5b16c 100644 --- a/planarity/c/graphLib/lowLevelUtils/apiutils.h +++ b/planarity/c/graphLib/lowLevelUtils/apiutils.h @@ -13,26 +13,42 @@ extern "C" #include "stdio.h" -// N.B. Every time this is used to create a string for a message or -// error message, the developer must check that there will not be a -// memory overwrite error. #define MAXLINE 1024 -// N.B. Every time you're trying to read a 32-bit int from a string, -// you should only need to read this many characters: an optional '-', -// followed by 10 digits (max signed 32-bit int value is 2,147,483,647). -// One must always allocate an additional byte for the null-terminator! +// The string representation for an integer must account for: an optional '-', +// then 10 digits (max signed 32-bit int), and a null-terminator #define MAXCHARSFOR32BITINT 11 +#if defined(_MSC_VER) && !defined(__llvm__) && !defined(__INTEL_COMPILER) +#define APPLY_FORMAT_ATTRIBUTE 0 +#elif defined(__has_attribute) +#define APPLY_FORMAT_ATTRIBUTE __has_attribute(format) +#elif defined(__GNUC__) || defined(__clang__) +#define APPLY_FORMAT_ATTRIBUTE 1 +#else +#define APPLY_FORMAT_ATTRIBUTE 0 +#endif + +#if APPLY_FORMAT_ATTRIBUTE +#if defined(__GNUC__) && !defined(__clang__) +#define FORMAT_PRINTF(formatIndex, firstArg) __attribute__((format(gnu_printf, formatIndex, firstArg))) +#else +#define FORMAT_PRINTF(formatIndex, firstArg) __attribute__((format(printf, formatIndex, firstArg))) +#endif +#else +#define FORMAT_PRINTF(formatIndex, firstArg) +#endif + extern int quietMode; - extern int getQuietModeSetting(void); - extern void setQuietModeSetting(int); + // These methods control whether gp_ErrorMessage() and gp_Message() calls + // emit output or skip producing output (the default) + int gp_GetQuietModeFlag(void); + void gp_SetQuietModeFlag(int newQuietModeFlag); - extern void Message(char const *message); - extern void ErrorMessage(char const *message); + extern void gp_Message(char const *message, ...) FORMAT_PRINTF(1, 2); + extern void gp_ErrorMessage(char const *message, ...) FORMAT_PRINTF(1, 2); - int GetNumCharsToReprInt(int theNum, int *numCharsRequired); #ifdef __cplusplus } #endif diff --git a/planarity/c/graphLib/lowLevelUtils/apiutils.private.h b/planarity/c/graphLib/lowLevelUtils/apiutils.private.h new file mode 100644 index 0000000..c057bb6 --- /dev/null +++ b/planarity/c/graphLib/lowLevelUtils/apiutils.private.h @@ -0,0 +1,58 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ +#ifndef APIUTILS_PRIVATE_H +#define APIUTILS_PRIVATE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* PRIVATE FUNCTIONS FOR ADDITIONAL INFORMATIONAL LOGGING. + + If LOGGING is defined by uncommenting it below, then log-related lines + write to the log, and otherwise they no-op. + + By default, neither release nor DEBUG builds including LOGGING. + Logging is used to see more details of how various algorithms + handle a particular graph. */ + +// #define LOGGING +#ifdef LOGGING + +#define _gp_LogLine _LogLine +#define _gp_Log _Log + + void _LogLine(const char *Line); + void _Log(const char *Line); + +#define _gp_MakeLogStr1 _MakeLogStr1 +#define _gp_MakeLogStr2 _MakeLogStr2 +#define _gp_MakeLogStr3 _MakeLogStr3 +#define _gp_MakeLogStr4 _MakeLogStr4 +#define _gp_MakeLogStr5 _MakeLogStr5 + + char *_MakeLogStr1(const char *format, int); + char *_MakeLogStr2(const char *format, int, int); + char *_MakeLogStr3(const char *format, int, int, int); + char *_MakeLogStr4(const char *format, int, int, int, int); + char *_MakeLogStr5(const char *format, int, int, int, int, int); + +#else +#define _gp_LogLine(Line) +#define _gp_Log(Line) +#define _gp_MakeLogStr1(format, one) +#define _gp_MakeLogStr2(format, one, two) +#define _gp_MakeLogStr3(format, one, two, three) +#define _gp_MakeLogStr4(format, one, two, three, four) +#define _gp_MakeLogStr5(format, one, two, three, four, five) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/planarity/c/graphLib/lowLevelUtils/appconst.h b/planarity/c/graphLib/lowLevelUtils/appconst.h index fbefb94..7543b52 100644 --- a/planarity/c/graphLib/lowLevelUtils/appconst.h +++ b/planarity/c/graphLib/lowLevelUtils/appconst.h @@ -27,14 +27,6 @@ See the LICENSE.TXT file for licensing information. #define FILE_DELIMITER '/' #endif -// When PROFILE is defined, prints out run-time stats on a number of subordinate -// routines in the embedder - -// #define PROFILE -#ifdef PROFILE -#include "platformTime.h" -#endif - /* Define DEBUG to get additional debugging. The default is to define it when MSC does */ #ifdef _DEBUG @@ -73,17 +65,22 @@ extern int debugNOTOK(void); #define NULL 0L #endif -// Define one of these to use faster 1-based arrays or -// the slower original 0-based arrays -#define USE_FASTER_1BASEDARRAYS +// Define one of these to use 1-based arrays or the original 0-based arrays +// It used to be true that the 1-based arrays were faster, but compiler +// optimizations have come a long way in two decades. +// +// The main advantages of 1-based arrays are readability of the data, +// that NIL is still an index within array bounds, that 1-based supports +// 0-based files but not the reverse, and continuing the long-time default. +#define USE_1BASEDARRAYS // #define USE_0BASEDARRAYS #ifdef USE_0BASEDARRAYS -#undef USE_FASTER_1BASEDARRAYS +#undef USE_1BASEDARRAYS #endif /* Array indices are used as pointers, and NIL means bad pointer */ -#ifdef USE_FASTER_1BASEDARRAYS +#ifdef USE_1BASEDARRAYS // This definition is used with 1-based array indexing #define NIL 0 #define NIL_CHAR 0x00 @@ -93,14 +90,4 @@ extern int debugNOTOK(void); #define NIL_CHAR 0xFF #endif -/******************************************************************** - A few simple integer selection macros - ********************************************************************/ - -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#define MAX(x, y) ((x) > (y) ? (x) : (y)) - -#define MIN3(x, y, z) MIN(MIN((x), (y)), MIN((y), (z))) -#define MAX3(x, y, z) MAX(MAX((x), (y)), MAX((y), (z))) - #endif diff --git a/planarity/c/graphLib/lowLevelUtils/listcoll.c b/planarity/c/graphLib/lowLevelUtils/listcoll.c index 83a5429..9a703a6 100644 --- a/planarity/c/graphLib/lowLevelUtils/listcoll.c +++ b/planarity/c/graphLib/lowLevelUtils/listcoll.c @@ -80,7 +80,7 @@ listCollectionP LCNew(int N) if (N <= 0) return theListColl; - theListColl = (listCollectionP)malloc(sizeof(listCollectionRec)); + theListColl = (listCollectionP)malloc(sizeof(listCollectionStruct)); if (theListColl != NULL) { theListColl->List = (lcnode *)malloc(N * sizeof(lcnode)); diff --git a/planarity/c/graphLib/lowLevelUtils/listcoll.h b/planarity/c/graphLib/lowLevelUtils/listcoll.h index 2608373..df98bd2 100644 --- a/planarity/c/graphLib/lowLevelUtils/listcoll.h +++ b/planarity/c/graphLib/lowLevelUtils/listcoll.h @@ -20,13 +20,14 @@ extern "C" int prev, next; } lcnode; - typedef struct + struct listCollectionStruct { int N; lcnode *List; - } listCollectionRec; + }; - typedef listCollectionRec *listCollectionP; + typedef struct listCollectionStruct listCollectionStruct; + typedef listCollectionStruct *listCollectionP; listCollectionP LCNew(int N); void LCFree(listCollectionP *pListColl); diff --git a/planarity/c/graphLib/lowLevelUtils/platformTime.h b/planarity/c/graphLib/lowLevelUtils/platformTime.h deleted file mode 100644 index bd44cdf..0000000 --- a/planarity/c/graphLib/lowLevelUtils/platformTime.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PLATFORM_TIME -#define PLATFORM_TIME - -/* -Copyright (c) 1997-2026, John M. Boyer -All rights reserved. -See the LICENSE.TXT file for licensing information. -*/ - -// NOTE: Since platformTime.h is only #include'd by appconst.h, and since appconst.h -// #define's WINDOWS before including platformTime.h, we condition on WINDOWS being defined. -#ifdef WINDOWS - -#include -#include - -#define platform_time DWORD -#define platform_GetTime(timeVar) (timeVar = GetTickCount()) -#define platform_GetDuration(startTime, endTime) ((double)(endTime - startTime) / 1000.0) - -#else - -#include - -typedef struct -{ - clock_t hiresTime; - time_t lowresTime; -} platform_time; - -#define platform_GetTime(timeVar) (timeVar.hiresTime = clock(), timeVar.lowresTime = time(NULL)) - -// Many flavors of Unix have CLOCKS_PER_SEC at 1 million, and clock_t as a 4 byte long integer -// which means that the clock() construct has a resolution of only about 2000 seconds -// If we're getting a duration longer than that, then we fall back to the coarser time() measure - -#define platform_GetDuration(startTime, endTime) ( \ - ((double)(endTime.lowresTime - startTime.lowresTime)) > 2000 ? ((double)(endTime.lowresTime - startTime.lowresTime)) : ((double)(endTime.hiresTime - startTime.hiresTime)) / CLOCKS_PER_SEC) - -/* -#define platform_time clock_t -#define platform_GetTime() clock() -#define platform_GetDuration(startTime, endTime) (((double) (endTime - startTime)) / CLOCKS_PER_SEC) -*/ - -/* -#define platform_time time_t -#define platform_GetTime() time((time_t *)NULL) -#define platform_GetDuration(startTime, endTime) ((double) (endTime - startTime)) -*/ - -#endif - -#endif diff --git a/planarity/c/graphLib/lowLevelUtils/stack.c b/planarity/c/graphLib/lowLevelUtils/stack.c index 9ded98d..01db674 100644 --- a/planarity/c/graphLib/lowLevelUtils/stack.c +++ b/planarity/c/graphLib/lowLevelUtils/stack.c @@ -12,7 +12,7 @@ stackP sp_New(int capacity) { stackP theStack; - theStack = (stackP)malloc(sizeof(stack)); + theStack = (stackP)malloc(sizeof(stackStruct)); if (theStack != NULL) { diff --git a/planarity/c/graphLib/lowLevelUtils/stack.h b/planarity/c/graphLib/lowLevelUtils/stack.h index e2cb891..2c772fc 100644 --- a/planarity/c/graphLib/lowLevelUtils/stack.h +++ b/planarity/c/graphLib/lowLevelUtils/stack.h @@ -15,13 +15,14 @@ extern "C" // includes mem functions like memcpy #include - typedef struct + struct stackStruct { int *S; int size, capacity; - } stack; + }; - typedef stack *stackP; + typedef struct stackStruct stackStruct; + typedef stackStruct *stackP; stackP sp_New(int); void sp_Free(stackP *); diff --git a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.c b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.c index 0571d56..063ba21 100644 --- a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.c +++ b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.c @@ -7,7 +7,11 @@ See the LICENSE.TXT file for licensing information. #include "graphDrawPlanar.h" #include "graphDrawPlanar.private.h" -#include "../graph.h" +// For definition of zero-based IO flag +#include "../io/graphIO.h" + +// For LOGGING-related declarations +#include "../lowLevelUtils/apiutils.private.h" #include #include @@ -32,6 +36,10 @@ int _ComputeEdgeRanges(DrawPlanarContext *context); int _GetNextExternalFaceVertex(graphP theGraph, int curVertex, int *pPrevLink); char *_RenderToString(graphP theEmbedding); +#ifdef LOGGING +void _LogEdgeList(graphP theEmbedding, listCollectionP edgeList, int edgeListHead); +#endif + /******************************************************************** _ComputeVisibilityRepresentation() @@ -79,7 +87,7 @@ int _ComputeVertexPositions(DrawPlanarContext *context) int v, vertpos; vertpos = 0; - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) { // For each DFS tree root in the embedding, we // compute the vertex positions @@ -189,7 +197,7 @@ int _ComputeVertexPositions(DrawPlanarContext *context) int _ComputeVertexPositionsInComponent(DrawPlanarContext *context, int root, int *pVertpos) { graphP theEmbedding = context->theGraph; - listCollectionP theOrder = LCNew(gp_VertexArraySize(theEmbedding)); + listCollectionP theOrder = LCNew(gp_UpperBoundVertices(theEmbedding)); int W, P, C, V, e; if (theOrder == NULL) @@ -297,7 +305,7 @@ void _LogEdgeList(graphP theEmbedding, listCollectionP edgeList, int edgeListHea _gp_Log("EdgeList: [ "); - while (gp_IsEdge(theGraph, eIndex)) + while (gp_IsEdge(theEmbedding, eIndex)) { e = (eIndex << 1); eTwin = gp_GetTwin(theEmbedding, e); @@ -348,7 +356,7 @@ int _ComputeEdgePositions(DrawPlanarContext *context) return NOTOK; } - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) vertexOrder[context->VI[v].pos] = v; // Allocate the edge list of size M. @@ -358,7 +366,7 @@ int _ComputeEdgePositions(DrawPlanarContext *context) // represented by a pair of adjacent edge records // at index 2X. - if (gp_GetM(theEmbedding) > 0 && (edgeList = LCNew(gp_EdgeArrayStart(theEmbedding) / 2 + gp_GetM(theEmbedding))) == NULL) + if (gp_GetM(theEmbedding) > 0 && (edgeList = LCNew(gp_LowerBoundEdges(theEmbedding) / 2 + gp_GetM(theEmbedding))) == NULL) { free(vertexOrder); vertexOrder = NULL; @@ -370,7 +378,7 @@ int _ComputeEdgePositions(DrawPlanarContext *context) // Each vertex starts out with a NIL generator edge. - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) gp_SetVertexVisitedInfo(theEmbedding, v, NIL); // Perform the vertical sweep of the combinatorial embedding, using @@ -517,7 +525,7 @@ int _ComputeVertexRanges(DrawPlanarContext *context) graphP theEmbedding = context->theGraph; int v = NIL, e = NIL, min = NIL, max = NIL; - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) { min = gp_GetM(theEmbedding) + 1; max = NIL; @@ -561,15 +569,14 @@ int _ComputeVertexRanges(DrawPlanarContext *context) int _ComputeEdgeRanges(DrawPlanarContext *context) { graphP theEmbedding = context->theGraph; - int e, eTwin, EsizeOccupied, v1, v2, pos1, pos2; + int e, eTwin, v1, v2, pos1, pos2; // Deleted edges are not supported, nor should they be in the embedding, so // this is just a reality check that avoids an in-use test inside the loop if (sp_NonEmpty(theEmbedding->edgeHoles)) return NOTOK; - EsizeOccupied = gp_EdgeInUseArraySize(theEmbedding); - for (e = gp_EdgeArrayStart(theEmbedding); e < EsizeOccupied; e += 2) + for (e = gp_LowerBoundEdges(theEmbedding); e < gp_UpperBoundEdges(theEmbedding); e += 2) { eTwin = gp_GetTwin(theEmbedding, e); @@ -798,7 +805,8 @@ char *_RenderToString(graphP theEmbedding) int N = gp_GetN(theEmbedding); int M = gp_GetM(theEmbedding); int zeroBasedVertexOffset = 0; - int n, m, EsizeOccupied, v, vRange, e, eRange, Mid, Pos; + int n, m, v, vRange, eRange, Mid, Pos; + int e; char *visRep = (char *)malloc(sizeof(char) * ((M + 1) * 2 * N + 1)); char numBuffer[32]; @@ -820,10 +828,10 @@ char *_RenderToString(graphP theEmbedding) // If we are supposed to write 0-based output, then we have to set this variable to indicate // how much to subtract from each vertex index based on whether this library has been // compiled with 0-based or 1-based array indexing for the in-memory data structure (i.e., - // compiled with USE_FASTER_1BASEDARRAYS USE_0BASEDARRAYS). + // compiled with USE_1BASEDARRAYS versus USE_0BASEDARRAYS). // The macro invoked is responsive to the compile-time difference. - if (gp_GetGraphFlags(theEmbedding) & FLAGS_ZEROBASEDIO) - zeroBasedVertexOffset = gp_GetFirstVertex(theGraph); + if (gp_GetGraphFlags(theEmbedding) & GRAPHFLAGS_ZEROBASEDIO) + zeroBasedVertexOffset = gp_LowerBoundVertexStorage(theEmbedding); // Clear the space for (n = 0; n < N; n++) @@ -839,7 +847,7 @@ char *_RenderToString(graphP theEmbedding) } // Draw the vertices - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) { Pos = context->VI[v].pos; for (vRange = context->VI[v].start; vRange <= context->VI[v].end; vRange++) @@ -865,8 +873,7 @@ char *_RenderToString(graphP theEmbedding) } // Draw the edges - EsizeOccupied = gp_EdgeInUseArraySize(theEmbedding); - for (e = gp_EdgeArrayStart(theEmbedding); e < EsizeOccupied; e += 2) + for (e = gp_LowerBoundEdges(theEmbedding); e < gp_UpperBoundEdges(theEmbedding); e += 2) { Pos = context->E[e].pos; for (eRange = context->E[e].start; eRange < context->E[e].end; eRange++) @@ -964,7 +971,7 @@ int gp_DrawPlanar_RenderToFile(graphP theEmbedding, char *theFileName) int _CheckVisibilityRepresentationIntegrity(DrawPlanarContext *context) { graphP theEmbedding = context->theGraph; - int v, e, eTwin, EsizeOccupied, epos, eposIndex; + int v, e, eTwin, epos, eposIndex; if (sp_NonEmpty(context->theGraph->edgeHoles)) return NOTOK; @@ -974,7 +981,7 @@ int _CheckVisibilityRepresentationIntegrity(DrawPlanarContext *context) /* Test whether the vertex values make sense and whether the vertex positions are unique. */ - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) { if (gp_GetM(theEmbedding) > 0) { @@ -987,21 +994,20 @@ int _CheckVisibilityRepresentationIntegrity(DrawPlanarContext *context) } // Has the vertex position been used by a vertex before vertex v? - if (gp_GetVisited(theEmbedding, context->VI[v].pos + gp_GetFirstVertex(theEmbedding))) + if (gp_GetVisited(theEmbedding, context->VI[v].pos + gp_LowerBoundVertexStorage(theEmbedding))) return NOTOK; // Mark the vertex position as used by vertex v. // Note that this marking is made on some other vertex unrelated to v // We're just reusing the vertex visited array as cheap storage for a // detector of reusing vertex position integers. - gp_SetVisited(theEmbedding, context->VI[v].pos + gp_GetFirstVertex(theEmbedding)); + gp_SetVisited(theEmbedding, context->VI[v].pos + gp_LowerBoundVertexStorage(theEmbedding)); } /* Test whether the edge values make sense and whether the edge positions are unique */ - EsizeOccupied = gp_EdgeInUseArraySize(theEmbedding); - for (e = gp_EdgeArrayStart(theEmbedding); e < EsizeOccupied; e += 2) + for (e = gp_LowerBoundEdges(theEmbedding); e < gp_UpperBoundEdges(theEmbedding); e += 2) { /* Each edge has two index locations in the edge information array */ eTwin = gp_GetTwin(theEmbedding, e); @@ -1025,7 +1031,7 @@ int _CheckVisibilityRepresentationIntegrity(DrawPlanarContext *context) can use the visited flags in the graph's edges to tell us whether the positions are being reused. */ - eposIndex = (epos << 1) + gp_EdgeArrayStart(theEmbedding); + eposIndex = (epos << 1) + gp_LowerBoundEdgeStorage(theEmbedding); eTwin = gp_GetTwin(theEmbedding, eposIndex); if (gp_GetEdgeVisited(theEmbedding, eposIndex) || gp_GetEdgeVisited(theEmbedding, eTwin)) @@ -1038,12 +1044,11 @@ int _CheckVisibilityRepresentationIntegrity(DrawPlanarContext *context) /* Test whether any edge intersects any vertex position for a vertex that is not an endpoint of the edge. */ - EsizeOccupied = gp_EdgeInUseArraySize(theEmbedding); - for (e = gp_EdgeArrayStart(theEmbedding); e < EsizeOccupied; e += 2) + for (e = gp_LowerBoundEdges(theEmbedding); e < gp_UpperBoundEdges(theEmbedding); e += 2) { eTwin = gp_GetTwin(theEmbedding, e); - for (v = gp_GetFirstVertex(theEmbedding); gp_VertexInRangeAscending(theEmbedding, v); v++) + for (v = gp_LowerBoundVertices(theEmbedding); v < gp_UpperBoundVertices(theEmbedding); ++v) { /* If the vertex is an endpoint of the edge, then... */ diff --git a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.h b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.h index 5d8a461..4eebb98 100644 --- a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.h +++ b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.h @@ -7,7 +7,7 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graphStructures.h" +#include "graphPlanarity.h" #ifdef __cplusplus extern "C" diff --git a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.private.h b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.private.h index 1b560b1..23b07cb 100644 --- a/planarity/c/graphLib/planarityRelated/graphDrawPlanar.private.h +++ b/planarity/c/graphLib/planarityRelated/graphDrawPlanar.private.h @@ -7,7 +7,7 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "../planarityRelated/graphPlanarity.private.h" #ifdef __cplusplus extern "C" @@ -80,7 +80,7 @@ extern "C" DrawPlanar_VertexInfoP VI; // Overloaded function pointers - graphFunctionTable functions; + graphFunctionTableStruct functions; } DrawPlanarContext; diff --git a/planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c b/planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c index 6943eb5..58cd3ce 100644 --- a/planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c +++ b/planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c @@ -4,12 +4,15 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include - -#include "graphDrawPlanar.private.h" #include "graphDrawPlanar.h" +#include "graphDrawPlanar.private.h" + +// Need to save and restore a graph flag related to IO +#include "../io/graphIO.h" + +#include -extern void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int); +extern void _ClearVertexVisitedFlags(graphP theGraph, int); extern void _CollectDrawingData(DrawPlanarContext *context, int RootVertex, int W, int WPrevLink); extern int _BreakTie(DrawPlanarContext *context, int BicompRoot, int W, int WPrevLink); @@ -35,7 +38,7 @@ int _DrawPlanar_CheckEmbeddingIntegrity(graphP theGraph, graphP origGraph); int _DrawPlanar_CheckObstructionIntegrity(graphP theGraph, graphP origGraph); int _DrawPlanar_InitGraph(graphP theGraph, int N); -void _DrawPlanar_ReinitializeGraph(graphP theGraph); +void _DrawPlanar_ReinitGraph(graphP theGraph); int _DrawPlanar_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity); int _DrawPlanar_SortVertices(graphP theGraph); @@ -78,6 +81,9 @@ int gp_ExtendWith_DrawPlanar(graphP theGraph) { DrawPlanarContext *context = NULL; + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + // If the drawing feature has already been attached to the graph, // then there is no need to attach it again gp_FindExtension(theGraph, DRAWPLANAR_ID, (void *)&context); @@ -86,6 +92,10 @@ int gp_ExtendWith_DrawPlanar(graphP theGraph) return OK; } + // Ensure theGraph is a Planarity Graph + if (gp_ExtendWith_Planarity(theGraph) != OK) + return NOTOK; + // Allocate a new extension context context = (DrawPlanarContext *)malloc(sizeof(DrawPlanarContext)); if (context == NULL) @@ -102,7 +112,7 @@ int gp_ExtendWith_DrawPlanar(graphP theGraph) // Put the overload functions into the context function table. // gp_AddExtension will overload the graph's functions with these, and // return the base function pointers in the context function table - memset(&context->functions, 0, sizeof(graphFunctionTable)); + memset(&context->functions, 0, sizeof(graphFunctionTableStruct)); context->functions.fpMergeBicomps = _DrawPlanar_MergeBicomps; context->functions.fpHandleInactiveVertex = _DrawPlanar_HandleInactiveVertex; @@ -111,7 +121,7 @@ int gp_ExtendWith_DrawPlanar(graphP theGraph) context->functions.fpCheckObstructionIntegrity = _DrawPlanar_CheckObstructionIntegrity; context->functions.fpInitGraph = _DrawPlanar_InitGraph; - context->functions.fpReinitializeGraph = _DrawPlanar_ReinitializeGraph; + context->functions.fpReinitGraph = _DrawPlanar_ReinitGraph; context->functions.fpEnsureEdgeCapacity = _DrawPlanar_EnsureEdgeCapacity; context->functions.fpSortVertices = _DrawPlanar_SortVertices; @@ -198,8 +208,8 @@ void _DrawPlanar_ClearStructures(DrawPlanarContext *context) int _DrawPlanar_CreateStructures(DrawPlanarContext *context) { graphP theGraph = context->theGraph; - int VIsize = gp_VertexArraySize(theGraph); - int Esize = gp_EdgeArraySize(theGraph); + int VIsize = gp_UpperBoundVertices(theGraph); + int Esize = gp_UpperBoundEdgeStorage(theGraph); if (gp_GetN(theGraph) <= 0) return NOTOK; @@ -221,22 +231,19 @@ int _DrawPlanar_CreateStructures(DrawPlanarContext *context) ********************************************************************/ int _DrawPlanar_InitStructures(DrawPlanarContext *context) { -#ifdef USE_FASTER_1BASEDARRAYS - memset(context->VI, NIL_CHAR, gp_VertexArraySize(context->theGraph) * sizeof(DrawPlanar_VertexInfo)); - memset(context->E, NIL_CHAR, gp_EdgeArraySize(context->theGraph) * sizeof(DrawPlanar_EdgeRec)); + memset(context->E, 0, gp_UpperBoundEdgeStorage(context->theGraph) * sizeof(DrawPlanar_EdgeRec)); + +#ifdef USE_1BASEDARRAYS + memset(context->VI, NIL_CHAR, gp_UpperBoundVertices(context->theGraph) * sizeof(DrawPlanar_VertexInfo)); #else - int v, e, Esize; + int v; graphP theGraph = context->theGraph; if (gp_GetN(theGraph) <= 0) return NOTOK; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) _DrawPlanar_InitVertexInfo(context, v); - - Esize = gp_EdgeArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < Esize; e++) - _DrawPlanar_InitEdgeRec(context, e); #endif return OK; @@ -253,8 +260,8 @@ void *_DrawPlanar_DupContext(void *pContext, void *theGraph) if (newContext != NULL) { - int VIsize = gp_VertexArraySize((graphP)theGraph); - int Esize = gp_EdgeArraySize((graphP)theGraph); + int VIsize = gp_UpperBoundVertices((graphP)theGraph); + int Esize = gp_UpperBoundEdgeStorage((graphP)theGraph); *newContext = *context; @@ -307,7 +314,7 @@ int _DrawPlanar_InitGraph(graphP theGraph, int N) theGraph->N = N; theGraph->NV = N; if (theGraph->edgeCapacity == 0) - theGraph->edgeCapacity = DEFAULT_EDGE_LIMIT * N; + theGraph->edgeCapacity = DEFAULT_EDGE_CAPACITY_FACTOR * N; if (_DrawPlanar_CreateStructures(context) != OK || _DrawPlanar_InitStructures(context) != OK) @@ -321,7 +328,7 @@ int _DrawPlanar_InitGraph(graphP theGraph, int N) /******************************************************************** ********************************************************************/ -void _DrawPlanar_ReinitializeGraph(graphP theGraph) +void _DrawPlanar_ReinitGraph(graphP theGraph) { DrawPlanarContext *context = NULL; gp_FindExtension(theGraph, DRAWPLANAR_ID, (void *)&context); @@ -329,7 +336,7 @@ void _DrawPlanar_ReinitializeGraph(graphP theGraph) if (context != NULL) { // Reinitialize the graph - context->functions.fpReinitializeGraph(theGraph); + context->functions.fpReinitGraph(theGraph); // Do the reinitialization that is specific to this module _DrawPlanar_InitStructures(context); @@ -369,7 +376,7 @@ int _DrawPlanar_SortVertices(graphP theGraph) DrawPlanar_VertexInfo temp; // Relabel the context data members that indicate vertices - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (gp_IsVertex(theGraph, context->VI[v].ancestor)) { @@ -382,8 +389,8 @@ int _DrawPlanar_SortVertices(graphP theGraph) // to the index values of the vertices. This could be done very easily with an extra array in // which, for each v, newVI[index of v] = VI[v]. However, this loop avoids memory allocation // by performing the operation (almost) in-place, except for the pre-existing visitation flags. - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + _ClearVertexVisitedFlags(theGraph, FALSE); + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { // If the correct data has already been placed into position v // by prior steps, then skip to the next vertex @@ -563,7 +570,7 @@ int _DrawPlanar_ReadPostprocess(graphP theGraph, char *extraData) else if (extraData != NULL && strlen(extraData) > 0) { - int v, e, tempInt, EsizeOccupied; + int v, tempInt, e; char line[64], tempChar; sprintf(line, "<%s>", DRAWPLANAR_NAME); @@ -577,7 +584,7 @@ int _DrawPlanar_ReadPostprocess(graphP theGraph, char *extraData) extraData = extraData + strlen(line) + 1; // Read the N lines of vertex information - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { sscanf(extraData, " %d%c %d %d %d", &tempInt, &tempChar, &context->VI[v].pos, @@ -588,8 +595,7 @@ int _DrawPlanar_ReadPostprocess(graphP theGraph, char *extraData) } // Read the lines that contain edge information - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e++) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); ++e) { sscanf(extraData, " %d%c %d %d %d", &tempInt, &tempChar, &context->E[e].pos, @@ -630,7 +636,7 @@ int _DrawPlanar_WritePostprocess(graphP theGraph, char **pExtraData) } else { - int v, e, EsizeOccupied; + int v, e; char line[64]; int maxLineSize = 64, extraDataPos = 0; char *extraData = (char *)calloc((1 + gp_GetN(theGraph) + 2 * gp_GetM(theGraph) + 1) * maxLineSize, sizeof(char)); @@ -643,11 +649,11 @@ int _DrawPlanar_WritePostprocess(graphP theGraph, char **pExtraData) // If we are supposed to write 0-based output, then we have to set these two variables to indicate // how much to subtract from each vertex and edge index based on whether this library has been // compiled with 0-based or 1-based array indexing for the in-memory data structure (i.e., compiled - // with USE_FASTER_1BASEDARRAYS USE_0BASEDARRAYS). The macros invoked are responsive to the difference. - if (gp_GetGraphFlags(theGraph) & FLAGS_ZEROBASEDIO) + // with USE_1BASEDARRAYS USE_0BASEDARRAYS). The macros invoked are responsive to the difference. + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_ZEROBASEDIO) { - zeroBasedVertexOffset = gp_GetFirstVertex(theGraph); - zeroBasedEdgeOffset = gp_EdgeArrayStart(theGraph); + zeroBasedVertexOffset = gp_LowerBoundVertexStorage(theGraph); + zeroBasedEdgeOffset = gp_LowerBoundEdgeStorage(theGraph); } // Bit of an unlikely case, but for safety, a bigger maxLineSize @@ -664,7 +670,7 @@ int _DrawPlanar_WritePostprocess(graphP theGraph, char **pExtraData) strcpy(extraData + extraDataPos, line); extraDataPos += (int)strlen(line); - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { sprintf(line, "%d: %d %d %d\n", v - zeroBasedVertexOffset, context->VI[v].pos, @@ -674,8 +680,7 @@ int _DrawPlanar_WritePostprocess(graphP theGraph, char **pExtraData) extraDataPos += (int)strlen(line); } - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e++) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); e++) { if (gp_EdgeInUse(theGraph, e)) { diff --git a/planarity/c/graphLib/planarityRelated/graphEmbed.c b/planarity/c/graphLib/planarityRelated/graphEmbed.c index c19106f..30f3e0f 100644 --- a/planarity/c/graphLib/planarityRelated/graphEmbed.c +++ b/planarity/c/graphLib/planarityRelated/graphEmbed.c @@ -6,22 +6,29 @@ See the LICENSE.TXT file for licensing information. #include -#include "../graph.h" +// This source file implements the main graph planarity/outerplanarity method, gp_Embed() +#include "../planarityRelated/graphPlanarity.h" +#include "../planarityRelated/graphPlanarity.private.h" +#include "../planarityRelated/graphOuterplanarity.h" +#include "../planarityRelated/graphOuterplanarity.private.h" -// Includes needed by _gp_EmbedFlagsValid(), until it become overloadable +// Includes needed by _gp_EmbedFlagsValid() #include "graphDrawPlanar.private.h" #include "../homeomorphSearch/graphK23Search.private.h" #include "../homeomorphSearch/graphK33Search.private.h" #include "../homeomorphSearch/graphK4Search.private.h" +// For LOGGING-related declarations +#include "../lowLevelUtils/apiutils.private.h" + /* Imported functions */ -extern void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int); +extern void _ClearVertexVisitedFlags(graphP theGraph, int); extern int _IsolateKuratowskiSubgraph(graphP theGraph, int v, int R); extern int _IsolateOuterplanarObstruction(graphP theGraph, int v, int R); -extern void _InitAnyTypeVertexRec(graphP theGraph, int v); +extern void _InitVertexRec(graphP theGraph, int v); extern int _gp_FindEdge(graphP theGraph, int u, int v); @@ -89,7 +96,7 @@ int _JoinBicomps(graphP theGraph); module that defines the embedding flag. ********************************************************************/ -int gp_Embed(graphP theGraph, int embedFlags) +int gp_Embed(graphP theGraph, unsigned embedFlags) { int v, e, c; int RetVal = OK; @@ -100,17 +107,35 @@ int gp_Embed(graphP theGraph, int embedFlags) // Preprocessing if (!_gp_EmbedFlagsValid(theGraph, embedFlags)) - return NOTOK; + { + // For historical reasons, the graph will be automatically extended with + // Planarity or Outerplanarity if not already done. + if (embedFlags == EMBEDFLAGS_PLANAR) + { + if (gp_ExtendWith_Planarity(theGraph) != OK) + return NOTOK; + } + else if (embedFlags == EMBEDFLAGS_OUTERPLANAR) + { + if (gp_ExtendWith_Outerplanarity(theGraph) != OK) + return NOTOK; + } + + // For other Graph subclasses, the caller must have invoked their + // ExtendWith method prior to calling gp_Embed() + else + return NOTOK; + } theGraph->embedFlags = embedFlags; // Initialize embedding data structures and allow extension algorithms // that overload the function to postprocess the DFS - if (theGraph->functions.fpEmbeddingInitialize(theGraph) != OK) + if (theGraph->functions->fpEmbeddingInitialize(theGraph) != OK) return NOTOK; // In reverse DFI order, embed the back edges from each vertex to its DFS descendants. - for (v = gp_GetLastVertex(theGraph); gp_VertexInRangeDescending(theGraph, v); v--) + for (v = gp_UpperBoundVertices(theGraph) - 1; v >= gp_LowerBoundVertices(theGraph); --v) { RetVal = OK; @@ -119,7 +144,7 @@ int gp_Embed(graphP theGraph, int embedFlags) e = gp_GetVertexFwdEdgeList(theGraph, v); while (gp_IsEdge(theGraph, e)) { - theGraph->functions.fpWalkUp(theGraph, v, e); + theGraph->functions->fpWalkUp(theGraph, v, e); e = gp_GetNextEdge(theGraph, e); if (e == gp_GetVertexFwdEdgeList(theGraph, v)) @@ -134,7 +159,7 @@ int gp_Embed(graphP theGraph, int embedFlags) { if (gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, c))) { - RetVal = theGraph->functions.fpWalkDown(theGraph, v, gp_GetBicompRootFromDFSChild(theGraph, c)); + RetVal = theGraph->functions->fpWalkDown(theGraph, v, gp_GetBicompRootFromDFSChild(theGraph, c)); // If Walkdown returns OK, then it is OK to proceed with edge addition. // Otherwise, if Walkdown returns NONEMBEDDABLE then we stop edge addition. if (RetVal != OK) @@ -152,7 +177,7 @@ int gp_Embed(graphP theGraph, int embedFlags) // Postprocessing to orient the embedding and merge any remaining separated bicomps. // Some extension algorithms may overload this function, e.g. to do nothing if they // have no need of an embedding. - return theGraph->functions.fpEmbedPostprocess(theGraph, v, RetVal); + return theGraph->functions->fpEmbedPostprocess(theGraph, v, RetVal); } /******************************************************************** @@ -172,8 +197,16 @@ int _gp_EmbedFlagsValid(graphP theGraph, int embedFlags) { // Currently, planar and outerplanar graph embedding and obstruction // isolation do not require an explicit extension. - if (embedFlags == EMBEDFLAGS_PLANAR || embedFlags == EMBEDFLAGS_OUTERPLANAR) - return TRUE; + if (embedFlags == EMBEDFLAGS_PLANAR) + { + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_PLANARITY) + return TRUE; + } + else if (embedFlags == EMBEDFLAGS_OUTERPLANAR) + { + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY) + return TRUE; + } // For other algorithms that are supported by explicit extensions, we // ensure they are attached (the attach methods exit early if it has @@ -237,11 +270,6 @@ int _EmbeddingInitialize(graphP theGraph) int DFI, v, R, uparent, u, uneighbor, e, f, eTwin, ePrev, eNext; int leastValue, child; -#ifdef PROFILE - platform_time start, end; - platform_GetTime(start); -#endif - _gp_LogLine("graphEmbed.c/_EmbeddingInitialize() start\n"); theStack = theGraph->theStack; @@ -258,12 +286,12 @@ int _EmbeddingInitialize(graphP theGraph) // We clear the visited flags of vertices because they are used to determine // which vertices have already been visited as the DFS traverses theGraph. - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); // This outer loop processes each connected component of a disconnected graph // No need to compare v < N since DFI will reach N when inner loop processes the // last connected component in the graph - for (DFI = v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, DFI); v++) + for (DFI = v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { // Skip numbered vertices to cause the outerloop to find the // next DFS tree root in a disconnected graph @@ -372,14 +400,14 @@ int _EmbeddingInitialize(graphP theGraph) } // The graph is now DFS numbered - theGraph->graphFlags |= FLAGS_DFSNUMBERED; + theGraph->graphFlags |= GRAPHFLAGS_DFSNUMBERED; // (6) Now that all vertices have a DFI in the index member, we can sort vertices if (gp_SortVertices(theGraph) != OK) return NOTOK; - // Loop through the vertices and virtual vertices to... - for (v = gp_GetLastVertex(theGraph); gp_VertexInRangeDescending(theGraph, v); v--) + // Loop through the vertices to... + for (v = gp_UpperBoundVertices(theGraph) - 1; v >= gp_LowerBoundVertices(theGraph); --v) { // (7) Initialize for pertinence management gp_SetVertexVisitedInfo(theGraph, v, gp_GetN(theGraph)); @@ -434,11 +462,6 @@ int _EmbeddingInitialize(graphP theGraph) _gp_LogLine("graphEmbed.c/_EmbeddingInitialize() end\n"); -#ifdef PROFILE - platform_GetTime(end); - printf("Initialize embedding in %.3lf seconds.\n", platform_GetDuration(start, end)); -#endif - return OK; } @@ -613,7 +636,7 @@ void _MergeVertex(graphP theGraph, int W, int WPrevLink, int R) } // Erase the entries in R, which is a root copy that is no longer needed - _InitAnyTypeVertexRec(theGraph, R); + _InitVertexRec(theGraph, R); } /******************************************************************** @@ -704,7 +727,7 @@ int _MergeBicomps(graphP theGraph, int v, int RootVertex, int W, int WPrevLink) } // Now we push R into Z, eliminating R - theGraph->functions.fpMergeVertex(theGraph, Z, ZPrevLink, R); + theGraph->functions->fpMergeVertex(theGraph, Z, ZPrevLink, R); } return OK; @@ -945,10 +968,10 @@ int _WalkDown(graphP theGraph, int v, int RootVertex) // edge to W to form a new proper face in the embedding. if (sp_NonEmpty(theGraph->theStack)) { - if ((RetVal = theGraph->functions.fpMergeBicomps(theGraph, v, RootVertex, W, WPrevLink)) != OK) + if ((RetVal = theGraph->functions->fpMergeBicomps(theGraph, v, RootVertex, W, WPrevLink)) != OK) return RetVal; } - theGraph->functions.fpEmbedBackEdgeToDescendant(theGraph, RootSide, RootVertex, W, WPrevLink); + theGraph->functions->fpEmbedBackEdgeToDescendant(theGraph, RootSide, RootVertex, W, WPrevLink); // Clear W's pertinentEdge since the forward edge record it contained has been embedded gp_SetVertexPertinentEdge(theGraph, W, NIL); @@ -1004,7 +1027,7 @@ int _WalkDown(graphP theGraph, int v, int RootVertex) // Let the application decide whether it can unblock the bicomp. // The core planarity/outerplanarity embedder simply isolates a // planarity/outerplanary obstruction and returns NONEMBEDDABLE - if ((RetVal = theGraph->functions.fpHandleBlockedBicomp(theGraph, v, RootVertex, R)) != OK) + if ((RetVal = theGraph->functions->fpHandleBlockedBicomp(theGraph, v, RootVertex, R)) != OK) return RetVal; // If an extension algorithm cleared the blockage, then we pop W and WPrevLink @@ -1047,7 +1070,7 @@ int _WalkDown(graphP theGraph, int v, int RootVertex) // inactive vertices, but the extFace links above achieve the same result with less work. else { - if (theGraph->functions.fpHandleInactiveVertex(theGraph, RootVertex, &W, &WPrevLink) != OK) + if (theGraph->functions->fpHandleInactiveVertex(theGraph, RootVertex, &W, &WPrevLink) != OK) return NOTOK; } } @@ -1067,7 +1090,7 @@ int _WalkDown(graphP theGraph, int v, int RootVertex) { // If an extension to core planarity indicates it is OK to proceed despite having detected // unembedded forward edges, then advance to the forward edges for the next child, if any - if ((RetVal = theGraph->functions.fpHandleBlockedBicomp(theGraph, v, RootVertex, RootVertex)) == OK) + if ((RetVal = theGraph->functions->fpHandleBlockedBicomp(theGraph, v, RootVertex, RootVertex)) == OK) _AdvanceFwdEdgeList(theGraph, v, RootEdgeChild, nextChild); return RetVal; @@ -1276,13 +1299,11 @@ int _EmbedPostprocess(graphP theGraph, int v, int edgeEmbeddingResult) int _OrientVerticesInEmbedding(graphP theGraph) { - int R; - sp_ClearStack(theGraph->theStack); // For each vertex, obtain the associated bicomp root location and, // if it is still in use as a bicomp root, orient the vertices in the bicomp - for (R = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, R); R++) + for (int R = gp_LowerBoundVirtualVertices(theGraph); R < gp_UpperBoundVirtualVertices(theGraph); ++R) { if (gp_VirtualVertexInUse(theGraph, R)) { @@ -1371,9 +1392,7 @@ int _OrientVerticesInBicomp(graphP theGraph, int BicompRoot, int PreserveSigns) int _JoinBicomps(graphP theGraph) { - int R; - - for (R = gp_GetFirstVirtualVertex(theGraph); gp_VirtualVertexInRangeAscending(theGraph, R); R++) + for (int R = gp_LowerBoundVirtualVertices(theGraph); R < gp_UpperBoundVirtualVertices(theGraph); ++R) { // If the bicomp root is still active (i.e. an in-use virtual vertex) // then merge it with its parent copy vertex (non-virtual) diff --git a/planarity/c/graphLib/planarityRelated/graphIsolator.c b/planarity/c/graphLib/planarityRelated/graphIsolator.c index 71bf986..2badeb5 100644 --- a/planarity/c/graphLib/planarityRelated/graphIsolator.c +++ b/planarity/c/graphLib/planarityRelated/graphIsolator.c @@ -6,7 +6,9 @@ See the LICENSE.TXT file for licensing information. #define GRAPHISOLATOR_C -#include "../graph.h" +// This source file implements subroutines of the main Planarity method +#include "../planarityRelated/graphPlanarity.h" +#include "../planarityRelated/graphPlanarity.private.h" /* Imported functions */ @@ -77,15 +79,15 @@ int _IsolateKuratowskiSubgraph(graphP theGraph, int v, int R) /* Call the appropriate isolator */ - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) RetVal = _IsolateMinorA(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_B) + else if (theGraph->IC->minorType & MINORTYPE_B) RetVal = _IsolateMinorB(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_C) + else if (theGraph->IC->minorType & MINORTYPE_C) RetVal = _IsolateMinorC(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_D) + else if (theGraph->IC->minorType & MINORTYPE_D) RetVal = _IsolateMinorD(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_E) + else if (theGraph->IC->minorType & MINORTYPE_E) RetVal = _IsolateMinorE(theGraph); else RetVal = NOTOK; @@ -104,7 +106,7 @@ int _IsolateKuratowskiSubgraph(graphP theGraph, int v, int R) int _InitializeIsolatorContext(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; /* Obtains the edges connecting X and Y to ancestors of the current vertex */ @@ -117,7 +119,7 @@ int _InitializeIsolatorContext(graphP theGraph) This child is the subtree root containing vertices with connections to both the current vertex and an ancestor of the current vertex. */ - if (theGraph->IC.minorType & MINORTYPE_B) + if (theGraph->IC->minorType & MINORTYPE_B) { int SubtreeRoot = gp_GetVertexLastPertinentRootChild(theGraph, IC->w); @@ -137,7 +139,7 @@ int _InitializeIsolatorContext(graphP theGraph) if (_FindUnembeddedEdgeToCurVertex(theGraph, IC->w, &IC->dw) != TRUE) return NOTOK; - if (theGraph->IC.minorType & MINORTYPE_E) + if (theGraph->IC->minorType & MINORTYPE_E) if (_FindUnembeddedEdgeToAncestor(theGraph, IC->z, &IC->uz, &IC->dz) != TRUE) return NOTOK; } @@ -151,10 +153,10 @@ int _InitializeIsolatorContext(graphP theGraph) int _IsolateMinorA(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) @@ -169,11 +171,11 @@ int _IsolateMinorA(graphP theGraph) int _IsolateMinorB(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), - MAX3(IC->ux, IC->uy, IC->uz)) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), + MAX3(IC->ux, IC->uy, IC->uz)) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) @@ -188,7 +190,7 @@ int _IsolateMinorB(graphP theGraph) int _IsolateMinorC(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (gp_GetObstructionMark(theGraph, IC->px) == ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW) { @@ -206,7 +208,7 @@ int _IsolateMinorC(graphP theGraph) // Note: The x-y path is already marked, due to identifying the type of non-planarity minor if (_MarkDFSPathsToDescendants(theGraph) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) return NOTOK; @@ -220,11 +222,11 @@ int _IsolateMinorC(graphP theGraph) int _IsolateMinorD(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; // Note: The x-y and v-z paths are already marked, due to identifying the type of non-planarity minor if (_MarkPathAlongBicompExtFace(theGraph, IC->x, IC->y) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN(IC->ux, IC->uy), IC->r) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) @@ -239,7 +241,7 @@ int _IsolateMinorD(graphP theGraph) int _IsolateMinorE(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; /* Minor E1: Isolate a K3,3 homeomorph */ @@ -265,7 +267,7 @@ int _IsolateMinorE(graphP theGraph) // Note: The x-y path is already marked, due to identifying the type of non-planarity minor if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), IC->r) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), IC->r) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) @@ -283,7 +285,7 @@ int _IsolateMinorE(graphP theGraph) int _IsolateMinorE1(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (gp_GetObstructionMark(theGraph, IC->z) == ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW) { @@ -306,8 +308,8 @@ int _IsolateMinorE1(graphP theGraph) // but the x-y path is also included in minor C, so we let it stay marked since the minor C // isolator also assumes the x-y path has been marked by non-planarity minor type identification IC->z = IC->uz = IC->dz = NIL; - theGraph->IC.minorType ^= MINORTYPE_E; - theGraph->IC.minorType |= (MINORTYPE_C | MINORTYPE_E1); + theGraph->IC->minorType ^= MINORTYPE_E; + theGraph->IC->minorType |= (MINORTYPE_C | MINORTYPE_E1); return _IsolateMinorC(theGraph); } @@ -320,7 +322,7 @@ int _IsolateMinorE1(graphP theGraph) int _IsolateMinorE2(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; // Note: The x-y path was already marked, due to identifying E as the type of non-planarity minor, // but we're reducing to Minor A, which does not include the x-y path, so the visited flags are @@ -331,8 +333,8 @@ int _IsolateMinorE2(graphP theGraph) IC->dw = IC->dz; IC->z = IC->uz = IC->dz = NIL; - theGraph->IC.minorType ^= MINORTYPE_E; - theGraph->IC.minorType |= (MINORTYPE_A | MINORTYPE_E2); + theGraph->IC->minorType ^= MINORTYPE_E; + theGraph->IC->minorType |= (MINORTYPE_A | MINORTYPE_E2); return _IsolateMinorA(theGraph); } @@ -342,7 +344,7 @@ int _IsolateMinorE2(graphP theGraph) int _IsolateMinorE3(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (IC->ux < IC->uy) { @@ -358,13 +360,13 @@ int _IsolateMinorE3(graphP theGraph) } // Note: The x-y path is already marked, due to identifying E as the type of non-planarity minor - if (theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), IC->r) != OK || + if (theGraph->functions->fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), IC->r) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) return NOTOK; - theGraph->IC.minorType |= MINORTYPE_E3; + theGraph->IC->minorType |= MINORTYPE_E3; return OK; } @@ -374,7 +376,7 @@ int _IsolateMinorE3(graphP theGraph) int _IsolateMinorE4(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (IC->px != IC->x) { @@ -390,14 +392,14 @@ int _IsolateMinorE4(graphP theGraph) } // Note: The x-y path is already marked, due to identifying E as the type of non-planarity minor - if (theGraph->functions.fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), - MAX3(IC->ux, IC->uy, IC->uz)) != OK || + if (theGraph->functions->fpMarkDFSPath(theGraph, MIN3(IC->ux, IC->uy, IC->uz), + MAX3(IC->ux, IC->uy, IC->uz)) != OK || _MarkDFSPathsToDescendants(theGraph) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkUnembeddedEdges(theGraph) != OK) return NOTOK; - theGraph->IC.minorType |= MINORTYPE_E4; + theGraph->IC->minorType |= MINORTYPE_E4; return OK; } @@ -497,7 +499,7 @@ int _FindUnembeddedEdgeToCurVertex(graphP theGraph, int cutVertex, int *pDescend { int subtreeRoot = gp_GetVertexFirstPertinentRootChild(theGraph, cutVertex); - return _FindUnembeddedEdgeToSubtree(theGraph, theGraph->IC.v, + return _FindUnembeddedEdgeToSubtree(theGraph, theGraph->IC->v, subtreeRoot, pDescendant); } } @@ -628,7 +630,7 @@ int _MarkDFSPath(graphP theGraph, int ancestor, int descendant) { // This loop traverses all vertices from descendant to ancestor, // including intervening bicomp roots (which are virtual vertices) - if (gp_IsNotAnyTypeVertex(theGraph, descendant)) + if (descendant == NIL) return NOTOK; // If we are at a bicomp root, then ascend to its non-virtual @@ -659,7 +661,7 @@ int _MarkDFSPath(graphP theGraph, int ancestor, int descendant) // The found parent may be a non-virtual or a virtual vertex. // If the latter, then it will be marked visited, and then the // next iteration of the loop will hop up to its non-virtual - if (gp_IsNotAnyTypeVertex(theGraph, parent)) + if (parent == NIL) return NOTOK; // Mark the edge @@ -681,18 +683,18 @@ int _MarkDFSPath(graphP theGraph, int ancestor, int descendant) int _MarkDFSPathsToDescendants(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->x, IC->dx) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->y, IC->dy) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->x, IC->dx) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->y, IC->dy) != OK) return NOTOK; if (gp_IsVertex(theGraph, IC->dw)) - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK) return NOTOK; if (gp_IsVertex(theGraph, IC->dz)) - if (theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dz) != OK) + if (theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dz) != OK) return NOTOK; return OK; @@ -704,7 +706,7 @@ int _MarkDFSPathsToDescendants(graphP theGraph) int _AddAndMarkUnembeddedEdges(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_AddAndMarkEdge(theGraph, IC->ux, IC->dx) != OK || _AddAndMarkEdge(theGraph, IC->uy, IC->dy) != OK) @@ -819,7 +821,7 @@ int _DeleteUnmarkedVerticesAndEdges(graphP theGraph) preprocessing. We now put them back into the adjacency lists (and we do not mark them), so they can be properly deleted below. */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { while (gp_IsEdge(theGraph, e = gp_GetVertexFwdEdgeList(theGraph, v))) _AddBackEdge(theGraph, v, gp_GetNeighbor(theGraph, e)); @@ -828,7 +830,7 @@ int _DeleteUnmarkedVerticesAndEdges(graphP theGraph) /* Now we delete all unmarked edges. We don't delete vertices from the embedding, but the ones we should delete will become degree zero. */ - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { e = gp_GetFirstEdge(theGraph, v); while (gp_IsEdge(theGraph, e)) diff --git a/planarity/c/graphLib/planarityRelated/graphNonplanar.c b/planarity/c/graphLib/planarityRelated/graphNonplanar.c index 95a95ce..ba345ac 100644 --- a/planarity/c/graphLib/planarityRelated/graphNonplanar.c +++ b/planarity/c/graphLib/planarityRelated/graphNonplanar.c @@ -6,7 +6,9 @@ See the LICENSE.TXT file for licensing information. #define GRAPHNONPLANAR_C -#include "../graph.h" +// This source file implements subroutines of the main graph planarity method +#include "../planarityRelated/graphPlanarity.h" +#include "../planarityRelated/graphPlanarity.private.h" /* Imported functions */ @@ -37,6 +39,18 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex); int _MarkZtoRPath(graphP theGraph); int _FindFuturePertinenceBelowXYPath(graphP theGraph); +/**************************************************************************** + _gp_GetObstructionMinorType() + ****************************************************************************/ + +int gp_GetObstructionMinorType(graphP theGraph) +{ + if (theGraph == NULL || theGraph->IC == NULL) + return MINORTYPE_NONE; + + return theGraph->IC->minorType; +} + /**************************************************************************** _ChooseTypeOfNonplanarityMinor() ****************************************************************************/ @@ -50,8 +64,8 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) if (_InitializeNonplanarityContext(theGraph, v, R) != OK) return NOTOK; - R = theGraph->IC.r; - W = theGraph->IC.w; + R = theGraph->IC->r; + W = theGraph->IC->w; /* If the root copy is not a root copy of the current vertex v, then the Walkdown terminated because it couldn't find @@ -59,7 +73,7 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) if (gp_GetVertexFromBicompRoot(theGraph, R) != v) { - theGraph->IC.minorType |= MINORTYPE_A; + theGraph->IC->minorType |= MINORTYPE_A; return OK; } @@ -70,18 +84,18 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) { if (gp_GetVertexLowpoint(theGraph, gp_GetVertexLastPertinentRootChild(theGraph, W)) < v) { - theGraph->IC.minorType |= MINORTYPE_B; + theGraph->IC->minorType |= MINORTYPE_B; return OK; } } /* Find the highest obstructing X-Y path */ - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; - Px = theGraph->IC.px; - Py = theGraph->IC.py; + Px = theGraph->IC->px; + Py = theGraph->IC->py; /* If either point of attachment is 'high' (P_x closer to R than X or P_y closer to R than Y along external face), then we've @@ -90,7 +104,7 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) if (gp_GetObstructionMark(theGraph, Px) == ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW || gp_GetObstructionMark(theGraph, Py) == ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW) { - theGraph->IC.minorType |= MINORTYPE_C; + theGraph->IC->minorType |= MINORTYPE_C; return OK; } @@ -100,9 +114,9 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) if (_MarkZtoRPath(theGraph) != OK) return NOTOK; - if (gp_IsVertex(theGraph, theGraph->IC.z)) + if (gp_IsVertex(theGraph, theGraph->IC->z)) { - theGraph->IC.minorType |= MINORTYPE_D; + theGraph->IC->minorType |= MINORTYPE_D; return OK; } @@ -112,8 +126,8 @@ int _ChooseTypeOfNonplanarityMinor(graphP theGraph, int v, int R) Z = _FindFuturePertinenceBelowXYPath(theGraph); if (gp_IsVertex(theGraph, Z)) { - theGraph->IC.z = Z; - theGraph->IC.minorType |= MINORTYPE_E; + theGraph->IC->z = Z; + theGraph->IC->minorType |= MINORTYPE_E; return OK; } @@ -151,7 +165,7 @@ int _InitializeNonplanarityContext(graphP theGraph, int v, int R) // Blank out the isolator context, then assign the input graph reference // and the current vertext v into the context. _InitIsolatorContext(theGraph); - theGraph->IC.v = v; + theGraph->IC->v = v; // The bicomp root provided was the one on which the WalkDown was performed, // but in the case of Minor A, the central bicomp of the minor is at the top @@ -163,7 +177,7 @@ int _InitializeNonplanarityContext(graphP theGraph, int v, int R) sp_Pop2_Discard1(theGraph->theStack, R); } - theGraph->IC.r = R; + theGraph->IC->r = R; // A number of subroutines require the main bicomp of the minor to be // consistently oriented and its visited flags clear. @@ -177,11 +191,11 @@ int _InitializeNonplanarityContext(graphP theGraph, int v, int R) // Now we find the active vertices along both external face paths // extending from R. - _FindActiveVertices(theGraph, R, &theGraph->IC.x, &theGraph->IC.y); + _FindActiveVertices(theGraph, R, &theGraph->IC->x, &theGraph->IC->y); // Now, we obtain the pertinent vertex W on the lower external face // path between X and Y (that path that does not include R). - theGraph->IC.w = _FindPertinentVertex(theGraph); + theGraph->IC->w = _FindPertinentVertex(theGraph); // Now we can classify the vertices along the external face of the bicomp // rooted at R as 'high RXW', 'low RXW', 'high RXY', 'low RXY' @@ -263,7 +277,7 @@ int _GetNeighborOnExtFace(graphP theGraph, int curVertex, int *pPrevLink) void _FindActiveVertices(graphP theGraph, int R, int *pX, int *pY) { - int XPrevLink = 1, YPrevLink = 0, v = theGraph->IC.v; + int XPrevLink = 1, YPrevLink = 0, v = theGraph->IC->v; *pX = _GetNeighborOnExtFace(theGraph, R, &XPrevLink); *pY = _GetNeighborOnExtFace(theGraph, R, &YPrevLink); @@ -300,11 +314,11 @@ void _FindActiveVertices(graphP theGraph, int R, int *pX, int *pY) int _FindPertinentVertex(graphP theGraph) { - int W = theGraph->IC.x, WPrevLink = 1; + int W = theGraph->IC->x, WPrevLink = 1; W = _GetNeighborOnExtFace(theGraph, W, &WPrevLink); - while (W != theGraph->IC.y) + while (W != theGraph->IC->y) { if (PERTINENT(theGraph, W)) return W; @@ -327,10 +341,10 @@ int _SetVertexTypesForMarkingXYPath(graphP theGraph) int R, X, Y, W, Z, ZPrevLink, ZType; // Unpack the context for efficiency of loops - R = theGraph->IC.r; - X = theGraph->IC.x; - Y = theGraph->IC.y; - W = theGraph->IC.w; + R = theGraph->IC->r; + X = theGraph->IC->x; + Y = theGraph->IC->y; + W = theGraph->IC->w; // Ensure basic preconditions of this routine are met if (gp_IsNotVirtualVertex(theGraph, R) || gp_IsNotVertex(theGraph, X) || @@ -427,12 +441,12 @@ int _PopAndUnmarkVerticesAndEdges(graphP theGraph, int Z, int stackBottom) This method also sets the isolator context's points of attachment on the external face of the marked X-Y path, if there was an X-Y path. So, the caller can also use this call to decide if there was an X-Y path by - testing whether theGraph->IC.px and py have been set to non-NIL values. + testing whether theGraph->IC->px and py have been set to non-NIL values. ****************************************************************************/ int _MarkHighestXYPath(graphP theGraph) { - return _MarkClosestXYPath(theGraph, theGraph->IC.r); + return _MarkClosestXYPath(theGraph, theGraph->IC->r); } /**************************************************************************** @@ -452,12 +466,12 @@ int _MarkHighestXYPath(graphP theGraph) This method also sets the isolator context's points of attachment on the external face of the marked X-Y path, if there was an X-Y path. So, the caller can also use this call to decide if there was an X-Y path by - testing whether theGraph->IC.px and py have been set to non-NIL values. + testing whether theGraph->IC->px and py have been set to non-NIL values. ****************************************************************************/ int _MarkLowestXYPath(graphP theGraph) { - return _MarkClosestXYPath(theGraph, theGraph->IC.w); + return _MarkClosestXYPath(theGraph, theGraph->IC->w); } /**************************************************************************** @@ -477,7 +491,7 @@ int _MarkLowestXYPath(graphP theGraph) OK to indicate no internal failures, but on return the caller can detect whether there was an X-Y path by testing whether the attachment points in the isolator context have been set to non-NIL values. Specifically, test - whether theGraph->IC.px and py have been set to non-NIL values. The caller + whether theGraph->IC->px and py have been set to non-NIL values. The caller must decide whether the absence of an X-Y path is an error. For example, in core planarity, the proof of correctness guarantees an X-Y path exists by the time this method is called, so that caller would decide to return @@ -566,9 +580,9 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex) /* Initialization */ - R = theGraph->IC.r; - W = theGraph->IC.w; - theGraph->IC.px = theGraph->IC.py = NIL; + R = theGraph->IC->r; + W = theGraph->IC->w; + theGraph->IC->px = theGraph->IC->py = NIL; /* This method only makes sense for a targetVertex of R or W */ if (targetVertex != R && targetVertex != W) @@ -656,7 +670,7 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex) if (gp_GetObstructionMark(theGraph, Z) == ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW || gp_GetObstructionMark(theGraph, Z) == ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW) { - theGraph->IC.px = Z; + theGraph->IC->px = Z; if (_PopAndUnmarkVerticesAndEdges(theGraph, NIL, stackBottom2) != OK) return NOTOK; } @@ -671,7 +685,7 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex) (except the entry edge for P_x).*/ gp_SetVisited(theGraph, Z); - if (Z != theGraph->IC.px) + if (Z != theGraph->IC->px) { gp_SetEdgeVisited(theGraph, e); gp_SetEdgeVisited(theGraph, gp_GetTwin(theGraph, e)); @@ -684,7 +698,7 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex) if (gp_GetObstructionMark(theGraph, Z) == ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW || gp_GetObstructionMark(theGraph, Z) == ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW) { - theGraph->IC.py = Z; + theGraph->IC->py = Z; break; } } @@ -700,8 +714,8 @@ int _MarkClosestXYPath(graphP theGraph, int targetVertex) /* Return the result */ - if (!gp_IsVertex(theGraph, theGraph->IC.py)) - theGraph->IC.px = NIL; + if (!gp_IsVertex(theGraph, theGraph->IC->py)) + theGraph->IC->px = NIL; return OK; } @@ -745,10 +759,10 @@ int _MarkZtoRPath(graphP theGraph) /* Initialize */ - R = theGraph->IC.r; - Px = theGraph->IC.px; - Py = theGraph->IC.py; - theGraph->IC.z = NIL; + R = theGraph->IC->r; + Px = theGraph->IC->px; + Py = theGraph->IC->py; + theGraph->IC->z = NIL; /* Begin at Px and search its adjacency list for the edge leading to the first internal vertex of the X-Y path. */ @@ -784,7 +798,7 @@ int _MarkZtoRPath(graphP theGraph) /* Otherwise, store Z in the isolation context */ - theGraph->IC.z = Z; + theGraph->IC->z = Z; /* Walk the proper face starting with (Z, ZNextEdge) until we reach R, marking the vertices and edges encountered along the way, then Return OK. */ @@ -829,8 +843,8 @@ int _MarkZtoRPath(graphP theGraph) int _FindFuturePertinenceBelowXYPath(graphP theGraph) { - int Z = theGraph->IC.px, ZPrevLink = 1, - Py = theGraph->IC.py, v = theGraph->IC.v; + int Z = theGraph->IC->px, ZPrevLink = 1, + Py = theGraph->IC->py, v = theGraph->IC->v; Z = _GetNeighborOnExtFace(theGraph, Z, &ZPrevLink); diff --git a/planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c b/planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c index 8bedcbf..46a572a 100644 --- a/planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c +++ b/planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c @@ -4,7 +4,8 @@ All rights reserved. See the LICENSE.TXT file for licensing information. */ -#include "../graph.h" +#include "graphOuterplanarity.h" +#include "graphOuterplanarity.private.h" /* Imported functions */ @@ -53,14 +54,14 @@ int _ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) if (_InitializeNonplanarityContext(theGraph, v, R) != OK) return NOTOK; - R = theGraph->IC.r; - W = theGraph->IC.w; + R = theGraph->IC->r; + W = theGraph->IC->w; // If the root copy is not a root copy of the current vertex v, // then the Walkdown terminated on a descendant bicomp, which is Minor A. if (gp_GetVertexFromBicompRoot(theGraph, R) != v) { - theGraph->IC.minorType |= MINORTYPE_A; + theGraph->IC->minorType |= MINORTYPE_A; return OK; } @@ -71,12 +72,12 @@ int _ChooseTypeOfNonOuterplanarityMinor(graphP theGraph, int v, int R) // associated, so we test gp_IsVertex, not gp_IsVirtualVertex here. if (gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, W))) { - theGraph->IC.minorType |= MINORTYPE_B; + theGraph->IC->minorType |= MINORTYPE_B; return OK; } // The only other result is minor E (we will search for the X-Y path later) - theGraph->IC.minorType |= MINORTYPE_E; + theGraph->IC->minorType |= MINORTYPE_E; return OK; } @@ -102,9 +103,9 @@ int _IsolateOuterplanarObstruction(graphP theGraph, int v, int R) /* Find the path connecting the pertinent vertex w with the current vertex v */ - if (theGraph->IC.minorType & MINORTYPE_B) + if (theGraph->IC->minorType & MINORTYPE_B) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; int SubtreeRoot = gp_GetVertexLastPertinentRootChild(theGraph, IC->w); if (_FindUnembeddedEdgeToSubtree(theGraph, IC->v, SubtreeRoot, &IC->dw) != TRUE) @@ -112,7 +113,7 @@ int _IsolateOuterplanarObstruction(graphP theGraph, int v, int R) } else { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_FindUnembeddedEdgeToCurVertex(theGraph, IC->w, &IC->dw) != TRUE) return NOTOK; @@ -120,19 +121,19 @@ int _IsolateOuterplanarObstruction(graphP theGraph, int v, int R) /* For minor E, we need to find and mark an X-Y path */ - if (theGraph->IC.minorType & MINORTYPE_E) + if (theGraph->IC->minorType & MINORTYPE_E) { - if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC.py == NIL) + if (_MarkHighestXYPath(theGraph) != OK || theGraph->IC->py == NIL) return NOTOK; } /* Call the appropriate isolator */ - if (theGraph->IC.minorType & MINORTYPE_A) + if (theGraph->IC->minorType & MINORTYPE_A) RetVal = _IsolateOuterplanarityObstructionA(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_B) + else if (theGraph->IC->minorType & MINORTYPE_B) RetVal = _IsolateOuterplanarityObstructionB(theGraph); - else if (theGraph->IC.minorType & MINORTYPE_E) + else if (theGraph->IC->minorType & MINORTYPE_E) RetVal = _IsolateOuterplanarityObstructionE(theGraph); else RetVal = NOTOK; @@ -151,11 +152,11 @@ int _IsolateOuterplanarObstruction(graphP theGraph, int v, int R) int _IsolateOuterplanarityObstructionA(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->v, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->v, IC->r) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkEdge(theGraph, IC->v, IC->dw) != OK) return NOTOK; @@ -169,10 +170,10 @@ int _IsolateOuterplanarityObstructionA(graphP theGraph) int _IsolateOuterplanarityObstructionB(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkEdge(theGraph, IC->v, IC->dw) != OK) return NOTOK; @@ -186,10 +187,10 @@ int _IsolateOuterplanarityObstructionB(graphP theGraph) int _IsolateOuterplanarityObstructionE(graphP theGraph) { - isolatorContextP IC = &theGraph->IC; + isolatorContextP IC = theGraph->IC; if (_MarkPathAlongBicompExtFace(theGraph, IC->r, IC->r) != OK || - theGraph->functions.fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || + theGraph->functions->fpMarkDFSPath(theGraph, IC->w, IC->dw) != OK || _JoinBicomps(theGraph) != OK || _AddAndMarkEdge(theGraph, IC->v, IC->dw) != OK) return NOTOK; diff --git a/planarity/c/graphLib/planarityRelated/graphOuterplanarity.h b/planarity/c/graphLib/planarityRelated/graphOuterplanarity.h new file mode 100644 index 0000000..16773f5 --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphOuterplanarity.h @@ -0,0 +1,34 @@ +#ifndef GRAPHOUTERPLANARITY_H +#define GRAPHOUTERPLANARITY_H + +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#include "graphPlanarity.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +// Create an Outerplanarity Graph, i.e., subclass a Planarity Graph by extending it +// with the ability to perform planar graph embedding and obstruction isolation. +#define OUTERPLANARITY_NAME "Outerplanarity" + + int gp_ExtendWith_Outerplanarity(graphP theGraph); + int gp_Detach_Outerplanarity(graphP theGraph); + +/* Graph Flags: see gp_GetGraphFlags() + GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY is set by calling gp_ExtendWith_OuterPlanarity() + This is automatically by gp_Embed() if not already done. +*/ +#define GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY 131072 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/planarity/c/graphLib/planarityRelated/graphOuterplanarity.private.h b/planarity/c/graphLib/planarityRelated/graphOuterplanarity.private.h new file mode 100644 index 0000000..e158e7d --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphOuterplanarity.private.h @@ -0,0 +1,23 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHOUTERPLANARITY_PRIVATE_H +#define GRAPHOUTERPLANARITY_PRIVATE_H + +#include "graphPlanarity.private.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + // Currently nothing to add here. + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHPOUTERLANARITY_PRIVATE_H */ diff --git a/planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c b/planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c new file mode 100644 index 0000000..c2e640c --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c @@ -0,0 +1,66 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#include "graphOuterplanarity.h" +#include "graphOuterplanarity.private.h" + +#include + +/**************************************************************************** + gp_ExtendWith_Outerplanarity() + + This function is intended to subclass a Planarity Graph by extending it with + the outerplanar graph embedding and obstruction isolation capabilities. + If the given graph has not already been extended with Planarity, then + gp_ExtendWith_Planarity() is called. + + To use Outerplanarity during gp_Embed(), use EMBEDFLAGS_OUTERPLANAR. + + Returns OK for success, NOTOK for failure. + ****************************************************************************/ + +int gp_ExtendWith_Outerplanarity(graphP theGraph) +{ + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + + // If the Graph has already been extended with Outerplanarity, + // then just return successfully + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY) + return OK; + + // Ensure theGraph is a Planarity Graph + if (gp_ExtendWith_Planarity(theGraph) != OK) + return NOTOK; + + // Allocate supporting data structures as needed + + // Perform "on success" operations + theGraph->graphFlags |= GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY; + return OK; +} + +/******************************************************************** + gp_Detach_Outerplanarity() + + This function is intended to disinherit the outerplanar graph embedding + and obstruction isolation feature by removing the extension from the + graph, which also frees any outerplanarity-specific data structures. + + Clears GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY after detaching support + for Outerplanarity. + + Returns OK on success, NOTOK on failure + ********************************************************************/ + +int gp_Detach_Outerplanarity(graphP theGraph) +{ + // Free any data structures allocated by the ExtendWith function + + // Indicate successful detachment of Outerplanarity + theGraph->graphFlags &= ~GRAPHFLAGS_EXTENDEDWITH_OUTERPLANARITY; + return OK; +} diff --git a/planarity/c/graphLib/planarityRelated/graphPlanarity.h b/planarity/c/graphLib/planarityRelated/graphPlanarity.h new file mode 100644 index 0000000..b050484 --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphPlanarity.h @@ -0,0 +1,85 @@ +#ifndef GRAPHPLANARITY_H +#define GRAPHPLANARITY_H + +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#include "../graphDFSUtils.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +// Create a Planarity Graph, i.e., subclass a DFSUtils Graph by extending it with +// the ability to perform planar graph embedding and obstruction isolation. +#define PLANARITY_NAME "Planarity" + + int gp_ExtendWith_Planarity(graphP theGraph); + int gp_Detach_Planarity(graphP theGraph); + +/* Graph Flags: see gp_GetGraphFlags() + GRAPHFLAGS_EXTENDEDWITH_PLANARITY is set by calling gp_ExtendWith_Planarity() + This is automatically by gp_Embed() if not already done. +*/ +#define GRAPHFLAGS_EXTENDEDWITH_PLANARITY 65536 + + // Graph embedding and result validation methods + // The embedResult output by gp_Embed() and input to gp_TestEmbedResultIntegrity() + // can be OK if the graph is embedded or embeddable, NONEMBEDDABLE if a minimal + // subgraph obstructing embedding has been isolated, or NOTOK on error + int gp_Embed(graphP theGraph, unsigned embedFlags); + int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResult); + +// A return result value for gp_Embed() to indicate success prior to embedding completion, +// due to finding an obstruction to embedding. +#define NONEMBEDDABLE -1 + +// Below are the possible graph embedFlags to pass to gp_Embed() and which are +// then set into the graph by gp_Embed() and returned by this method. +#define gp_GetEmbedFlags(theGraph) ((theGraph)->embedFlags) + +#define EMBEDFLAGS_PLANAR 1 +#define EMBEDFLAGS_OUTERPLANAR 2 + +#define EMBEDFLAGS_DRAWPLANAR (4 | EMBEDFLAGS_PLANAR) + +#define EMBEDFLAGS_SEARCHFORK23 (8 | EMBEDFLAGS_OUTERPLANAR) +#define EMBEDFLAGS_SEARCHFORK33 (16 | EMBEDFLAGS_PLANAR) +#define EMBEDFLAGS_SEARCHFORK4 (32 | EMBEDFLAGS_OUTERPLANAR) + +// Reserve flag bits for possible future embedding-related extension modules +#define EMBEDFLAGS_SEARCHFORK5 (64 | EMBEDFLAGS_PLANAR) +#define EMBEDFLAGS_SEARCHFORK5MINOR (128 | EMBEDFLAGS_PLANAR) +#define EMBEDFLAGS_MAXIMALPLANARSUBGRAPH (256 | EMBEDFLAGS_PLANAR) +#define EMBEDFLAGS_PROJECTIVEPLANAR 512 +#define EMBEDFLAGS_TOROIDAL 1024 + + // After gp_Embed(), if the result is NONEMBEDDABLE, then this method + // returns the obstructing minor type from the list below. + // It is best to compare using a bitwise-and operation. + int gp_GetObstructionMinorType(graphP theGraph); + +#define MINORTYPE_NONE 0 +#define MINORTYPE_A 1 +#define MINORTYPE_B 2 +#define MINORTYPE_C 4 +#define MINORTYPE_D 8 +#define MINORTYPE_E 16 +#define MINORTYPE_E1 32 +#define MINORTYPE_E2 64 +#define MINORTYPE_E3 128 +#define MINORTYPE_E4 256 + +#define MINORTYPE_E5 512 +#define MINORTYPE_E6 1024 +#define MINORTYPE_E7 2048 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/planarity/c/graphLib/planarityRelated/graphPlanarity.private.h b/planarity/c/graphLib/planarityRelated/graphPlanarity.private.h new file mode 100644 index 0000000..9516ec6 --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphPlanarity.private.h @@ -0,0 +1,311 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#ifndef GRAPHPLANARITY_PRIVATE_H +#define GRAPHPLANARITY_PRIVATE_H + +#include "../graphDFSUtils.private.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +// PLANARITY-RELATED ONLY VERTEX FLAGS +// +// The ANYVERTEX_OBSTRUCTIONMARK_MASK bits are bits 2-4, 4+8+16=28 +// They are used by planarity-related algorithms to identify the four +// regions of the external face cycle of a bicomp, relative to an +// XY-path in the bicomp. +// Bit 2 - 4 if the OBSTRUCTIONMARK is set, 0 if not +// Bit 3 - 8 if the OBSTRUCTIONMARK indicates Y side, 0 if X side +// Bit 4 - 16 if the OBSTRUCTIONMARK indicates high, 0 if low +#define ANYVERTEX_OBSTRUCTIONMARK_MASK 28 + +// Call gp_GetObstructionMark, then compare to one of these four possibilities +// ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW - On the external face path between vertices R and X +// ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW - X or on the external face path between vertices X and W +// ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW - On the external face path between vertices R and Y +// ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW - Y or on the external face path between vertices Y and W +// ANYVERTEX_OBSTRUCTIONMARK_UNMARKED - corresponds to all three bits off +#define ANYVERTEX_OBSTRUCTIONMARK_HIGH_RXW 20 +#define ANYVERTEX_OBSTRUCTIONMARK_LOW_RXW 4 +#define ANYVERTEX_OBSTRUCTIONMARK_HIGH_RYW 28 +#define ANYVERTEX_OBSTRUCTIONMARK_LOW_RYW 12 +#define ANYVERTEX_OBSTRUCTIONMARK_UNMARKED 0 + +#define gp_GetObstructionMark(theGraph, v) (theGraph->V[v].flags & ANYVERTEX_OBSTRUCTIONMARK_MASK) +#define gp_ClearObstructionMark(theGraph, v) (theGraph->V[v].flags &= ~ANYVERTEX_OBSTRUCTIONMARK_MASK) +#define gp_SetObstructionMark(theGraph, v, type) (theGraph->V[v].flags |= type) +#define gp_ResetObstructionMark(theGraph, v, type) \ + (theGraph->V[v].flags = (theGraph->V[v].flags & ~ANYVERTEX_OBSTRUCTIONMARK_MASK) | type) + + /******************************************************************** + // PLANARITY-RELATED ONLY + // + This structure defines a pair of links used by each vertex and virtual vertex + to create "short circuit" paths that eliminate unimportant vertices from + the external face, enabling more efficient traversal of the external face. + + It is also possible to embed the "short circuit" edges, but this approach + creates a better separation of concerns, imparts greater clarity, and + removes exceptionalities for handling additional fake "short circuit" edges. + + vertex[2]: The two adjacent vertices along the external face, possibly + short-circuiting paths of inactive vertices. + */ + + struct extFaceLinkRec + { + int vertex[2]; + }; + + typedef struct extFaceLinkRec extFaceLinkRec; + typedef extFaceLinkRec *extFaceLinkRecP; + +#define gp_GetExtFaceVertex(theGraph, v, link) (theGraph->extFace[v].vertex[link]) +#define gp_SetExtFaceVertex(theGraph, v, link, theVertex) (theGraph->extFace[v].vertex[link] = theVertex) + + /******************************************************************** + // PLANARITY-RELATED ONLY + // + Planarity-specific additional vertex information. + + visitedInfo: enables algorithms to manage vertex visitation with more than + just a flag. For example, the planarity test flags visitation + as a step number that implicitly resets on each step, whereas + part of the planar drawing method signifies a first visitation + by storing the index of the first edge used to reach a vertex + pertinentEdge: Used by the planarity method; during Walkup, each vertex + that is directly adjacent via a back edge to the vertex v + currently being embedded will have the forward edge's index + stored in this field. During Walkdown, each vertex for which + this field is set will cause a back edge to be embedded. + Implicitly resets at each vertex step of the planarity method + pertinentRootsList: used by Walkup to store a list of child bicomp roots of + a vertex descendant of the current vertex that are pertinent + and must be merged by the Walkdown in order to embed the cycle + edges of the current vertex. Future pertinent child bicomp roots + are placed at the end of the list to ensure bicomps that are + only pertinent are processed first. + futurePertinentChild: indicates a DFS child with a lowpoint less than the + current vertex v. This member is initialized to the start of + the sortedDFSChildList and is advanced in a relaxed manner as + needed until one with a lowpoint less than v is found or until + there are no more children. + sortedDFSChildList: at the start of embedding, the list of DFS children of + this vertex is calculated in ascending order by DFI (sorted in + linear time). The list is used during Walkdown processing of + a vertex to process all of its children. It is also used in + future pertinence management when processing the ancestors of + the vertex. When a child C is merged into the same bicomp as + the vertex, it is removed from the list. + fwdEdgeList: at the start of embedding, the "back" edges from a vertex to + its DFS *descendants* (i.e. the forward edge records) are + separated from the main adjacency list and placed in a + circular list until they are embedded. The list is sorted in + ascending DFI order of the descendants (in linear time). + This member indicates (by index) a node in that list. + */ + + struct Planarity_VertexInfo + { + int visitedInfo; + + int pertinentEdge, + pertinentRoots, + futurePertinentChild, + sortedDFSChildList, + fwdEdgeList; + }; + + typedef struct Planarity_VertexInfo Planarity_VertexInfo; + typedef Planarity_VertexInfo *Planarity_VertexInfoP; + +#define gp_GetVertexVisitedInfo(theGraph, v) (theGraph->PVI[v].visitedInfo) +#define gp_SetVertexVisitedInfo(theGraph, v, theVisitedInfo) (theGraph->PVI[v].visitedInfo = theVisitedInfo) + +#define gp_GetVertexPertinentEdge(theGraph, v) (theGraph->PVI[v].pertinentEdge) +#define gp_SetVertexPertinentEdge(theGraph, v, e) (theGraph->PVI[v].pertinentEdge = e) + +#define gp_GetVertexPertinentRootsList(theGraph, v) (theGraph->PVI[v].pertinentRoots) +#define gp_SetVertexPertinentRootsList(theGraph, v, pertinentRootsHead) (theGraph->PVI[v].pertinentRoots = pertinentRootsHead) + +#define gp_GetVertexFirstPertinentRoot(theGraph, v) gp_GetBicompRootFromDFSChild(theGraph, theGraph->PVI[v].pertinentRoots) +#define gp_GetVertexFirstPertinentRootChild(theGraph, v) (theGraph->PVI[v].pertinentRoots) +#define gp_GetVertexLastPertinentRoot(theGraph, v) gp_GetBicompRootFromDFSChild(theGraph, LCGetPrev(theGraph->BicompRootLists, theGraph->PVI[v].pertinentRoots, NIL)) +#define gp_GetVertexLastPertinentRootChild(theGraph, v) LCGetPrev(theGraph->BicompRootLists, theGraph->PVI[v].pertinentRoots, NIL) + +#define gp_DeleteVertexPertinentRoot(theGraph, v, R) \ + gp_SetVertexPertinentRootsList(theGraph, v, \ + LCDelete(theGraph->BicompRootLists, \ + gp_GetVertexPertinentRootsList(theGraph, v), \ + gp_GetDFSChildFromBicompRoot(theGraph, R))) + +#define gp_PrependVertexPertinentRoot(theGraph, v, R) \ + gp_SetVertexPertinentRootsList(theGraph, v, \ + LCPrepend(theGraph->BicompRootLists, \ + gp_GetVertexPertinentRootsList(theGraph, v), \ + gp_GetDFSChildFromBicompRoot(theGraph, R))) + +#define gp_AppendVertexPertinentRoot(theGraph, v, R) \ + gp_SetVertexPertinentRootsList(theGraph, v, \ + LCAppend(theGraph->BicompRootLists, \ + gp_GetVertexPertinentRootsList(theGraph, v), \ + gp_GetDFSChildFromBicompRoot(theGraph, R))) + +#define gp_GetVertexFuturePertinentChild(theGraph, v) (theGraph->PVI[v].futurePertinentChild) +#define gp_SetVertexFuturePertinentChild(theGraph, v, theFuturePertinentChild) (theGraph->PVI[v].futurePertinentChild = theFuturePertinentChild) + +// Used to advance futurePertinentChild of w to the next separated DFS child with a lowpoint less than v +// Once futurePertinentChild advances past a child, no future planarity operation could make that child +// relevant to future pertinence. +#define gp_UpdateVertexFuturePertinentChild(theGraph, w, v) \ + while (gp_IsVertex(theGraph, theGraph->PVI[w].futurePertinentChild)) \ + { \ + /* Skip children that 1) aren't future pertinent, 2) have been merged into the bicomp with w */ \ + if (gp_GetVertexLowpoint(theGraph, theGraph->PVI[w].futurePertinentChild) >= v || \ + gp_IsNotSeparatedDFSChild(theGraph, theGraph->PVI[w].futurePertinentChild)) \ + { \ + theGraph->PVI[w].futurePertinentChild = \ + gp_GetVertexNextDFSChild(theGraph, w, gp_GetVertexFuturePertinentChild(theGraph, w)); \ + } \ + else \ + break; \ + } + +#define gp_GetVertexSortedDFSChildList(theGraph, v) (theGraph->PVI[v].sortedDFSChildList) +#define gp_SetVertexSortedDFSChildList(theGraph, v, theSortedDFSChildList) (theGraph->PVI[v].sortedDFSChildList = theSortedDFSChildList) + +#define gp_GetVertexNextDFSChild(theGraph, v, c) LCGetNext(theGraph->sortedDFSChildLists, gp_GetVertexSortedDFSChildList(theGraph, v), c) + +#define gp_AppendDFSChild(theGraph, v, c) \ + LCAppend(theGraph->sortedDFSChildLists, gp_GetVertexSortedDFSChildList(theGraph, v), c) + +#define gp_GetVertexFwdEdgeList(theGraph, v) (theGraph->PVI[v].fwdEdgeList) +#define gp_SetVertexFwdEdgeList(theGraph, v, theFwdEdgeList) (theGraph->PVI[v].fwdEdgeList = theFwdEdgeList) + + /******************************************************************** + // PLANARITY-RELATED ONLY + // + Variables needed in embedding by Kuratowski subgraph isolator: + minorType: the type of planarity obstruction found. + v: the current vertex being processed + r: the root of the bicomp on which the Walkdown failed + x,y: stopping vertices on bicomp rooted by r + w: pertinent vertex on ext. face path below x and y + px, py: attachment points of x-y path, + z: Unused except in minors D and E (not needed in A, B, C). + + ux,dx: endpoints of unembedded edge that helps connext x with + ancestor of v + uy,dy: endpoints of unembedded edge that helps connext y with + ancestor of v + dw: descendant endpoint in unembedded edge to v + uz,dz: endpoints of unembedded edge that helps connext z with + ancestor of v (for minors B and E, not A, C, D). + */ + + struct isolatorContextStruct + { + int minorType; + int v, r, x, y, w, px, py, z; + int ux, dx, uy, dy, dw, uz, dz; + }; + + typedef struct isolatorContextStruct isolatorContextStruct; + typedef isolatorContextStruct *isolatorContextP; + +//******************************************************************** +// A few simple integer selection macros for obstruction isolation +//******************************************************************** +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) + +#define MIN3(x, y, z) MIN(MIN((x), (y)), MIN((y), (z))) +#define MAX3(x, y, z) MAX(MAX((x), (y)), MAX((y), (z))) + +/******************************************************************** + PERTINENT() + A vertex is pertinent in a partially processed graph if there is an + unprocessed back edge between the vertex v whose edges are currently + being processed and either the vertex or a DFS descendant D of the + vertex not in the same bicomp as the vertex. + + The vertex is either directly adjacent to v by an unembedded back edge + or there is an unembedded back edge (v, D) and the vertex is a cut + vertex in the partially processed graph along the DFS tree path from + D to v. + + Pertinence is a dynamic property that can change for a vertex after + each edge addition. In other words, a vertex can become non-pertinent + during step v as more back edges to v are embedded. + + NOTE: Pertinent roots are stored using the DFS children with which + they are associated, so we test 'is vertex' (rather than virtual). + ********************************************************************/ +#define PERTINENT(theGraph, theVertex) \ + (gp_IsEdge(theGraph, gp_GetVertexPertinentEdge(theGraph, theVertex)) || \ + gp_IsVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theVertex))) + +#define NOTPERTINENT(theGraph, theVertex) \ + (gp_IsNotEdge(theGraph, gp_GetVertexPertinentEdge(theGraph, theVertex)) && \ + gp_IsNotVertex(theGraph, gp_GetVertexPertinentRootsList(theGraph, theVertex))) + +/******************************************************************** + FUTUREPERTINENT() + A vertex is future-pertinent in a partially processed graph if + there is an unprocessed back edge between a DFS ancestor A of the + vertex v whose edges are currently being processed and either + theVertex or a DFS descendant D of theVertex not in the same bicomp + as theVertex. + + Either theVertex is directly adjacent to A by an unembedded back edge + or there is an unembedded back edge (A, D) and theVertex is a cut + vertex in the partially processed graph along the DFS tree path from + D to A. + + If no more edges are added to the partially processed graph prior to + processing the edges of A, then the vertex would be pertinent. + The addition of edges to the partially processed graph can alter + both the pertinence and future pertinence of a vertex. For example, + if the vertex is pertinent due to an unprocessed back edge (v, D1) and + future pertinent due to an unprocessed back edge (A, D2), then the + vertex may lose both its pertinence and future pertinence when edge + (v, D1) is added if D2 is in the same subtree as D1. + + Generally, pertinence and future pertinence are dynamic properties + that can change for a vertex after each edge addition. + + Note that gp_UpdateVertexFuturePertinentChild() must be called before + this macro. Since it is a statement and not a void expression, the + desired commented out version does not compile (except with special + compiler extensions not assumed by this code). + ********************************************************************/ +#define FUTUREPERTINENT(theGraph, theVertex, v) \ + (theGraph->DVI[theVertex].leastAncestor < v || \ + (gp_IsVertex(theGraph, theGraph->PVI[theVertex].futurePertinentChild) && \ + theGraph->DVI[theGraph->PVI[theVertex].futurePertinentChild].lowpoint < v)) + +#define NOTFUTUREPERTINENT(theGraph, theVertex, v) \ + (theGraph->DVI[theVertex].leastAncestor >= v && \ + (gp_IsNotVertex(theGraph, theGraph->PVI[theVertex].futurePertinentChild) || \ + theGraph->DVI[theGraph->PVI[theVertex].futurePertinentChild].lowpoint >= v)) + +/******************************************************************** + INACTIVE() + For planarity algorithms, a vertex is inactive if it is neither pertinent + nor future pertinent. + ********************************************************************/ +#define INACTIVE(theGraph, theVertex, v) \ + (NOTPERTINENT(theGraph, theVertex) && \ + NOTFUTUREPERTINENT(theGraph, theVertex, v)) + +#ifdef __cplusplus +} +#endif + +#endif /* GRAPHPLANARITY_PRIVATE_H */ diff --git a/planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c b/planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c new file mode 100644 index 0000000..eb05f61 --- /dev/null +++ b/planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c @@ -0,0 +1,66 @@ +/* +Copyright (c) 1997-2026, John M. Boyer +All rights reserved. +See the LICENSE.TXT file for licensing information. +*/ + +#include "graphPlanarity.h" +#include "graphPlanarity.private.h" + +#include + +/**************************************************************************** + gp_ExtendWith_Planarity() + + This function is intended to subclass a DFSUtils Graph by extending it with + the planar graph embedding and obstruction isolation capabilities and any + additional required data structures. If the given graph has not already + been extended with DFSUtils, then gp_ExtendWith_DFSUtils() is called. + + To use Planarity during gp_Embed(), use EMBEDFLAGS_PLANAR. + + Returns OK for success, NOTOK for failure. + ****************************************************************************/ + +int gp_ExtendWith_Planarity(graphP theGraph) +{ + if (theGraph == NULL || gp_GetN(theGraph) <= 0) + return NOTOK; + + // If the Graph has already been extended with Planarity, + // then just return successfully + if (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_EXTENDEDWITH_PLANARITY) + return OK; + + // Ensure theGraph is a DFSUtils Graph + if (gp_ExtendWith_DFSUtils(theGraph) != OK) + return NOTOK; + + // Allocate supporting data structures as needed + + // Perform "on success" operations + theGraph->graphFlags |= GRAPHFLAGS_EXTENDEDWITH_PLANARITY; + return OK; +} + +/******************************************************************** + gp_Detach_Planarity() + + This function is intended to disinherit the planar graph embedding and + obstruction isolation feature by remove the extension from the graph, + which also frees any planarity-specific data structures. + + Clears GRAPHFLAGS_EXTENDEDWITH_PLANARITY after detaching support + for Planarity. + + Returns OK on success, NOTOK on failure + ********************************************************************/ + +int gp_Detach_Planarity(graphP theGraph) +{ + // Free any data structures allocated by the ExtendWith function + + // Indicate successful detachment of Outerplanarity + theGraph->graphFlags &= ~GRAPHFLAGS_EXTENDEDWITH_PLANARITY; + return OK; +} diff --git a/planarity/c/graphLib/planarityRelated/graphTests.c b/planarity/c/graphLib/planarityRelated/graphTests.c index ee10226..c59f382 100644 --- a/planarity/c/graphLib/planarityRelated/graphTests.c +++ b/planarity/c/graphLib/planarityRelated/graphTests.c @@ -6,10 +6,14 @@ See the LICENSE.TXT file for licensing information. #define GRAPHTEST_C -#include "../graph.h" -#include "../lowLevelUtils/stack.h" +// This source file implements the main graph planarity result integrity check method +// NOTE: Integrity checks for subclasses of Planarity Graph that are extended with +// extensions for advanced algorithms are performed by overloads of the +// integrity check function in those extensions, e.g., K33Search and DrawPlanar. +#include "graphPlanarity.h" +#include "graphPlanarity.private.h" -extern void _ClearAnyTypeVertexVisitedFlags(graphP theGraph, int); +extern void _ClearVertexVisitedFlags(graphP theGraph, int); /* Private function declarations (some exported to system) */ @@ -89,11 +93,11 @@ int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResu if (embedResult == OK) { - RetVal = theGraph->functions.fpCheckEmbeddingIntegrity(theGraph, origGraph); + RetVal = theGraph->functions->fpCheckEmbeddingIntegrity(theGraph, origGraph); } else if (embedResult == NONEMBEDDABLE) { - RetVal = theGraph->functions.fpCheckObstructionIntegrity(theGraph, origGraph); + RetVal = theGraph->functions->fpCheckObstructionIntegrity(theGraph, origGraph); } if (RetVal == OK) @@ -169,7 +173,7 @@ int _CheckEmbeddingIntegrity(graphP theGraph, graphP origGraph) int _CheckEmbeddingFacialIntegrity(graphP theGraph) { stackP theStack = theGraph->theStack; - int EsizeOccupied, v, e, eTwin, eStart, eNext, NumFaces, connectedComponents; + int v, e, eTwin, eStart, eNext, NumFaces, connectedComponents; if (theGraph == NULL) return NOTOK; @@ -183,14 +187,16 @@ int _CheckEmbeddingFacialIntegrity(graphP theGraph) /* Push all edge records (both parts of each edge) and set them all to unvisited */ - EsizeOccupied = gp_EdgeInUseArraySize(theGraph); - for (e = gp_EdgeArrayStart(theGraph); e < EsizeOccupied; e += 2) + for (e = gp_LowerBoundEdges(theGraph); e < gp_UpperBoundEdges(theGraph); e += 2) { // Except skip edge holes if (gp_EdgeInUse(theGraph, e)) { + // Push e and clear its visited flag sp_Push(theStack, e); gp_ClearEdgeVisited(theGraph, e); + + // And now the same for the twin of e eTwin = gp_GetTwin(theGraph, e); sp_Push(theStack, eTwin); gp_ClearEdgeVisited(theGraph, eTwin); @@ -232,7 +238,7 @@ int _CheckEmbeddingFacialIntegrity(graphP theGraph) so we do not subtract one. */ connectedComponents = 0; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (gp_IsDFSTreeRoot(theGraph, v)) { @@ -270,11 +276,11 @@ int _CheckAllVerticesOnExternalFace(graphP theGraph) int v; // Mark all vertices unvisited - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); // For each connected component, walk its external face and // mark the vertices as visited - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { if (gp_IsDFSTreeRoot(theGraph, v)) _MarkExternalFaceVertices(theGraph, v); @@ -282,7 +288,7 @@ int _CheckAllVerticesOnExternalFace(graphP theGraph) // If any vertex is unvisited, then the embedding is not an outerplanar // embedding, so we return NOTOK - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (!gp_GetVisited(theGraph, v)) return NOTOK; @@ -426,7 +432,7 @@ int _getImageVertices(graphP theGraph, int *degrees, int maxDegree, imageVertPos = 0; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) { degree = gp_GetVertexDegree(theGraph, v); if (degree == 1) @@ -483,7 +489,7 @@ int _TestForCompleteGraphObstruction(graphP theGraph, int numVerts, return FALSE; // We clear all the vertex visited flags - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); // For each pair of image vertices, we test that there is a path // between the two vertices. If so, the visited flags of the @@ -499,7 +505,7 @@ int _TestForCompleteGraphObstruction(graphP theGraph, int numVerts, // The visited flags should have marked only degree two vertices, // so for every marked vertex, we subtract one from the count of // the degree two vertices. - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (gp_GetVisited(theGraph, v)) degrees[2]--; @@ -564,7 +570,7 @@ int _TestForK33GraphObstruction(graphP theGraph, int *degrees, int *imageVerts) /* Now test the paths between each of the first three vertices and each of the last three vertices */ - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); for (imageVertPos = 0; imageVertPos < 3; imageVertPos++) for (K = 3; K < 6; K++) @@ -572,7 +578,7 @@ int _TestForK33GraphObstruction(graphP theGraph, int *degrees, int *imageVerts) imageVerts[K]) != TRUE) return FALSE; - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (gp_GetVisited(theGraph, v)) degrees[2]--; @@ -690,7 +696,7 @@ int _TestForK23GraphObstruction(graphP theGraph, int *degrees, int *imageVerts) Now test the paths between each of the degree 2 image vertices and imageVerts[1]. */ - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); for (imageVertPos = 2; imageVertPos < 5; imageVertPos++) { @@ -701,7 +707,7 @@ int _TestForK23GraphObstruction(graphP theGraph, int *degrees, int *imageVerts) gp_SetVisited(theGraph, imageVerts[imageVertPos]); } - for (v = gp_GetFirstVertex(theGraph); gp_VertexInRangeAscending(theGraph, v); v++) + for (v = gp_LowerBoundVertices(theGraph); v < gp_UpperBoundVertices(theGraph); ++v) if (gp_GetVisited(theGraph, v)) degrees[2]--; @@ -878,8 +884,8 @@ int _TestSubgraph(graphP theSubgraph, graphP theGraph) // If the graph is not sorted by DFI, but the alleged subgraph is, // then "unsort" the alleged subgraph so both have the same vertex order - if (!(gp_GetGraphFlags(theGraph) & FLAGS_SORTEDBYDFI) && - (gp_GetGraphFlags(theSubgraph) & FLAGS_SORTEDBYDFI)) + if (!(gp_GetGraphFlags(theGraph) & GRAPHFLAGS_SORTEDBYDFI) && + (gp_GetGraphFlags(theSubgraph) & GRAPHFLAGS_SORTEDBYDFI)) { invokeSortOnSubgraph = TRUE; gp_SortVertices(theSubgraph); @@ -887,8 +893,8 @@ int _TestSubgraph(graphP theSubgraph, graphP theGraph) // If the graph is not sorted by DFI, but the alleged subgraph is, // then "unsort" the alleged subgraph so both have the same vertex order - if (!(gp_GetGraphFlags(theSubgraph) & FLAGS_SORTEDBYDFI) && - (gp_GetGraphFlags(theGraph) & FLAGS_SORTEDBYDFI)) + if (!(gp_GetGraphFlags(theSubgraph) & GRAPHFLAGS_SORTEDBYDFI) && + (gp_GetGraphFlags(theGraph) & GRAPHFLAGS_SORTEDBYDFI)) { invokeSortOnGraph = TRUE; gp_SortVertices(theGraph); @@ -896,10 +902,10 @@ int _TestSubgraph(graphP theSubgraph, graphP theGraph) /* We clear all visitation flags */ - _ClearAnyTypeVertexVisitedFlags(theGraph, FALSE); + _ClearVertexVisitedFlags(theGraph, FALSE); /* For each vertex... */ - for (v = gp_GetFirstVertex(theSubgraph), degreeCount = 0; gp_VertexInRangeAscending(theSubgraph, v); v++) + for (v = gp_LowerBoundVertices(theSubgraph), degreeCount = 0; v < gp_UpperBoundVertices(theSubgraph); ++v) { /* For each neighbor w in the adjacency list of vertex v in the subgraph, set the visited flag in w in the graph */ diff --git a/planarity/classic/cplanarity.pxd b/planarity/classic/cplanarity.pxd index 6dc0476..a2d8f90 100644 --- a/planarity/classic/cplanarity.pxd +++ b/planarity/classic/cplanarity.pxd @@ -1,48 +1,59 @@ """Interface for Boyer's (c) planarity algorithms.""" -cdef extern from "../c/graphLib/graphStructures.h": - ctypedef struct baseGraphStructure: +cdef extern from "../c/graphLib/graph.h": + ctypedef struct graphStruct: pass - ctypedef baseGraphStructure * graphP + ctypedef graphStruct * graphP + + graphP gp_New() + int gp_InitGraph(graphP theGraph, int N) + void gp_Free(graphP *pGraph) ctypedef struct edgeRec: pass ctypedef edgeRec * edgeRecP - int gp_GetFirstVertex(graphP theGraph) - int gp_GetLastVertex(graphP theGraph) - int gp_GetFirstEdge(graphP theGraph, int v) - int gp_GetLastEdge(graphP theGraph, int v) - int gp_IsEdge(graphP theGraph, int v) - int gp_GetNeighbor(graphP theGraph, int v) - int gp_GetPrevEdge(graphP theGraph, int v) + int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) + int gp_DynamicAddEdge(graphP theGraph, int u, int ulink, int v, int vlink) + + int gp_IsEdge(graphP theGraph, int v) + int gp_GetNextEdge(graphP theGraph, int v) + int gp_GetPrevEdge(graphP theGraph, int v) + + int gp_GetNeighbor(graphP theGraph, int v) + + int EDGEFLAG_DIRECTION_INONLY, EDGEFLAG_DIRECTION_OUTONLY + int gp_GetDirection(graphP theGraph, int v) -cdef extern from "../c/graphLib/lowLevelUtils/appconst.h": - int OK, NOTOK, NULL + int gp_GetFirstEdge(graphP theGraph, int v) + int gp_GetLastEdge(graphP theGraph, int v) -cdef extern from "../c/graphLib/graph.h": - int WRITE_ADJLIST + int gp_LowerBoundVertices(graphP theGraph) + int gp_UpperBoundVertices(graphP theGraph) -cdef extern from "../c/graphLib/graphStructures.h": - int EMBEDFLAGS_PLANAR, NONEMBEDDABLE, EMBEDFLAGS_DRAWPLANAR - int EDGEFLAG_DIRECTION_INONLY, EDGEFLAG_DIRECTION_OUTONLY - graphP gp_New() - void gp_Free(graphP *pGraph) - int gp_InitGraph(graphP theGraph, int N) - int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) - int gp_Embed(graphP theGraph, int embedFlags) - int gp_Write(graphP theGraph, char *FileName, int Mode) +cdef extern from "../c/graphLib/graphDFSUtils.h": void gp_SortVertices(graphP theGraph) - int gp_ExtendWith_Planarity(graphP theGraph) - int gp_ExtendWith_Outerplanarity(graphP theGraph) + +cdef extern from "../c/graphLib/extensionSystem/graphExtensions.h": + int gp_FindExtension(graphP theGraph, int moduleID, void **pContext) + void *gp_GetExtension(graphP theGraph, int moduleID) + + +cdef extern from "../c/graphLib/io/graphIO.h": + int WRITE_ADJLIST + int gp_Write(graphP theGraph, char *FileName, int Mode) + + +cdef extern from "../c/graphLib/lowLevelUtils/appconst.h": + int OK, NOTOK, NULL cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.h": - int gp_DrawPlanar_RenderToString(graphP theEmbedding, char **pRenditionString); int gp_ExtendWith_DrawPlanar(graphP theGraph) + int gp_DrawPlanar_RenderToString(graphP theEmbedding, char **pRenditionString); cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.private.h": @@ -62,6 +73,15 @@ cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.private.h": DrawPlanar_EdgeRecP E DrawPlanar_VertexInfoP VI -cdef extern from "../c/graphLib/extensionSystem/graphExtensions.h": - void * gp_GetExtension(graphP theGraph, int moduleID) - int gp_FindExtension(graphP theGraph, int moduleID, void *pContext) + +cdef extern from "../c/graphLib/planarityRelated/graphOuterplanarity.h": + int gp_ExtendWith_Outerplanarity(graphP theGraph) + + +cdef extern from "../c/graphLib/planarityRelated/graphPlanarity.h": + int gp_ExtendWith_Planarity(graphP theGraph) + + int gp_Embed(graphP theGraph, int embedFlags) + + int NONEMBEDDABLE + int EMBEDFLAGS_PLANAR, EMBEDFLAGS_DRAWPLANAR diff --git a/planarity/classic/planarity.c b/planarity/classic/planarity.c index cf9068f..9295a37 100644 --- a/planarity/classic/planarity.c +++ b/planarity/classic/planarity.c @@ -11,7 +11,8 @@ "sources": [ "planarity/classic/planarity.pyx", "planarity/c/graphLib/graphDFSUtils.c", - "planarity/c/graphLib/graphUtils.c", + "planarity/c/graphLib/graphLib.c", + "planarity/c/graphLib/graph.c", "planarity/c/graphLib/io/g6-api-utilities.c", "planarity/c/graphLib/io/g6-read-iterator.c", "planarity/c/graphLib/io/strOrFile.c", @@ -26,10 +27,12 @@ "planarity/c/graphLib/homeomorphSearch/graphK33Search.c", "planarity/c/graphLib/homeomorphSearch/graphK23Search.c", "planarity/c/graphLib/planarityRelated/graphTests.c", + "planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphEmbed.c", "planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c", "planarity/c/graphLib/planarityRelated/graphNonplanar.c", "planarity/c/graphLib/planarityRelated/graphIsolator.c", + "planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c", "planarity/c/graphLib/lowLevelUtils/stack.c", @@ -1160,12 +1163,15 @@ static int __Pyx_init_co_variables(void) { /* Early includes */ #include #include -#include "../c/graphLib/graphStructures.h" -#include "../c/graphLib/lowLevelUtils/appconst.h" #include "../c/graphLib/graph.h" +#include "../c/graphLib/graphDFSUtils.h" +#include "../c/graphLib/extensionSystem/graphExtensions.h" +#include "../c/graphLib/io/graphIO.h" +#include "../c/graphLib/lowLevelUtils/appconst.h" #include "../c/graphLib/planarityRelated/graphDrawPlanar.h" #include "../c/graphLib/planarityRelated/graphDrawPlanar.private.h" -#include "../c/graphLib/extensionSystem/graphExtensions.h" +#include "../c/graphLib/planarityRelated/graphOuterplanarity.h" +#include "../c/graphLib/planarityRelated/graphPlanarity.h" #ifdef _OPENMP #include #endif /* _OPENMP */ @@ -2408,12 +2414,6 @@ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value); -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); - /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; @@ -2431,6 +2431,12 @@ typedef const char *__Pyx_TypeName; #define __Pyx_DECREF_TypeName(obj) #endif +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); + /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) @@ -2719,8 +2725,8 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati #define __pyx_kp_b_iso88591_A_q_Q_8_1A_AQ_xwaq __pyx_string_tab[94] #define __pyx_kp_b_iso88591_A_t1 __pyx_string_tab[95] #define __pyx_kp_b_iso88591_Q __pyx_string_tab[96] -#define __pyx_kp_b_iso88591_a_1D_5Qa_4q_Zq_a_a_E_avQ_q_Q_7 __pyx_string_tab[97] -#define __pyx_kp_b_iso88591_a_1D_5Qa_a_a_4q_Zq_E_avQ_Zq_j_A __pyx_string_tab[98] +#define __pyx_kp_b_iso88591_a_1D_6aq_a_a_at1_Qd_E_avQ_Zq_j __pyx_string_tab[97] +#define __pyx_kp_b_iso88591_a_1D_6aq_at1_Qd_a_a_E_avQ_q_Q_7 __pyx_string_tab[98] #define __pyx_int_1 __pyx_number_tab[0] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE @@ -3609,7 +3615,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx * seen = set() * for u,v in edges: # <<<<<<<<<<<<<< * if (u,v) not in seen and (v,u) not in seen: - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, */ if (likely(PyList_CheckExact(__pyx_v_edges)) || PyTuple_CheckExact(__pyx_v_edges)) { __pyx_t_12 = __pyx_v_edges; __Pyx_INCREF(__pyx_t_12); @@ -3719,7 +3725,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx * seen = set() * for u,v in edges: * if (u,v) not in seen and (v,u) not in seen: # <<<<<<<<<<<<<< - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, * self.nodemap[u], 0, */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) @@ -3753,10 +3759,10 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx /* "planarity/classic/planarity.pyx":53 * if (u,v) not in seen and (v,u) not in seen: - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, * self.nodemap[u], 0, # <<<<<<<<<<<<<< * self.nodemap[v], 0) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: */ if (unlikely(__pyx_v_self->nodemap == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); @@ -3768,10 +3774,10 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "planarity/classic/planarity.pyx":54 - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, * self.nodemap[u], 0, * self.nodemap[v], 0) # <<<<<<<<<<<<<< - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * cplanarity.gp_Free(&self.theGraph) */ if (unlikely(__pyx_v_self->nodemap == Py_None)) { @@ -3786,25 +3792,25 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx /* "planarity/classic/planarity.pyx":52 * for u,v in edges: * if (u,v) not in seen and (v,u) not in seen: - * status = cplanarity.gp_AddEdge(self.theGraph, # <<<<<<<<<<<<<< + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, # <<<<<<<<<<<<<< * self.nodemap[u], 0, * self.nodemap[v], 0) */ - __pyx_v_status = gp_AddEdge(__pyx_v_self->theGraph, __pyx_t_7, 0, __pyx_t_9, 0); + __pyx_v_status = gp_DynamicAddEdge(__pyx_v_self->theGraph, __pyx_t_7, 0, __pyx_t_9, 0); /* "planarity/classic/planarity.pyx":55 * self.nodemap[u], 0, * self.nodemap[v], 0) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * cplanarity.gp_Free(&self.theGraph) * raise RuntimeError("planarity: failed adding edge.") */ - __pyx_t_1 = (__pyx_v_status == NOTOK); + __pyx_t_1 = (__pyx_v_status != OK); if (unlikely(__pyx_t_1)) { /* "planarity/classic/planarity.pyx":56 * self.nodemap[v], 0) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * cplanarity.gp_Free(&self.theGraph) # <<<<<<<<<<<<<< * raise RuntimeError("planarity: failed adding edge.") * seen.add((u,v)) @@ -3812,7 +3818,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx gp_Free((&__pyx_v_self->theGraph)); /* "planarity/classic/planarity.pyx":57 - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * cplanarity.gp_Free(&self.theGraph) * raise RuntimeError("planarity: failed adding edge.") # <<<<<<<<<<<<<< * seen.add((u,v)) @@ -3834,7 +3840,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx /* "planarity/classic/planarity.pyx":55 * self.nodemap[u], 0, * self.nodemap[v], 0) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * cplanarity.gp_Free(&self.theGraph) * raise RuntimeError("planarity: failed adding edge.") */ @@ -3862,7 +3868,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx * seen = set() * for u,v in edges: * if (u,v) not in seen and (v,u) not in seen: # <<<<<<<<<<<<<< - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, * self.nodemap[u], 0, */ goto __pyx_L37; @@ -3925,7 +3931,7 @@ static int __pyx_pf_9planarity_7classic_9planarity_6PGraph___init__(struct __pyx * seen = set() * for u,v in edges: # <<<<<<<<<<<<<< * if (u,v) not in seen and (v,u) not in seen: - * status = cplanarity.gp_AddEdge(self.theGraph, + * status = cplanarity.gp_DynamicAddEdge(self.theGraph, */ } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; @@ -4118,7 +4124,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_4embed_planar(s * return * * status = cplanarity.gp_ExtendWith_Planarity(self.theGraph) # <<<<<<<<<<<<<< - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with planarity structures.") */ __pyx_v_status = gp_ExtendWith_Planarity(__pyx_v_self->theGraph); @@ -4126,16 +4132,16 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_4embed_planar(s /* "planarity/classic/planarity.pyx":73 * * status = cplanarity.gp_ExtendWith_Planarity(self.theGraph) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * raise RuntimeError("planarity: failed to extend graph with planarity structures.") * self.embedding = cplanarity.gp_Embed(self.theGraph, */ - __pyx_t_1 = (__pyx_v_status == NOTOK); + __pyx_t_1 = (__pyx_v_status != OK); if (unlikely(__pyx_t_1)) { /* "planarity/classic/planarity.pyx":74 * status = cplanarity.gp_ExtendWith_Planarity(self.theGraph) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with planarity structures.") # <<<<<<<<<<<<<< * self.embedding = cplanarity.gp_Embed(self.theGraph, * cplanarity.EMBEDFLAGS_PLANAR) @@ -4156,14 +4162,14 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_4embed_planar(s /* "planarity/classic/planarity.pyx":73 * * status = cplanarity.gp_ExtendWith_Planarity(self.theGraph) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * raise RuntimeError("planarity: failed to extend graph with planarity structures.") * self.embedding = cplanarity.gp_Embed(self.theGraph, */ } /* "planarity/classic/planarity.pyx":75 - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with planarity structures.") * self.embedding = cplanarity.gp_Embed(self.theGraph, # <<<<<<<<<<<<<< * cplanarity.EMBEDFLAGS_PLANAR) @@ -4207,7 +4213,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_4embed_planar(s * * def embed_drawplanar(self): # <<<<<<<<<<<<<< * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: */ /* Python wrapper */ @@ -4270,7 +4276,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_6embed_drawplan * * def embed_drawplanar(self): * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) # <<<<<<<<<<<<<< - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") */ __pyx_v_status = gp_ExtendWith_DrawPlanar(__pyx_v_self->theGraph); @@ -4278,16 +4284,16 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_6embed_drawplan /* "planarity/classic/planarity.pyx":82 * def embed_drawplanar(self): * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") * status = cplanarity.gp_Embed(self.theGraph, */ - __pyx_t_1 = (__pyx_v_status == NOTOK); + __pyx_t_1 = (__pyx_v_status != OK); if (unlikely(__pyx_t_1)) { /* "planarity/classic/planarity.pyx":83 * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") # <<<<<<<<<<<<<< * status = cplanarity.gp_Embed(self.theGraph, * cplanarity.EMBEDFLAGS_DRAWPLANAR) @@ -4308,14 +4314,14 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_6embed_drawplan /* "planarity/classic/planarity.pyx":82 * def embed_drawplanar(self): * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: # <<<<<<<<<<<<<< + * if status != cplanarity.OK: # <<<<<<<<<<<<<< * raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") * status = cplanarity.gp_Embed(self.theGraph, */ } /* "planarity/classic/planarity.pyx":84 - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: * raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") * status = cplanarity.gp_Embed(self.theGraph, # <<<<<<<<<<<<<< * cplanarity.EMBEDFLAGS_DRAWPLANAR) @@ -4376,7 +4382,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_6embed_drawplan * * def embed_drawplanar(self): # <<<<<<<<<<<<<< * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: */ /* function exit code */ @@ -4737,7 +4743,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_10kuratowski_ed /* "planarity/classic/planarity.pyx":108 * * - * def nodes(self,data=False): # <<<<<<<<<<<<<< + * def nodes(self, data=False): # <<<<<<<<<<<<<< * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context */ @@ -4836,16 +4842,16 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct DrawPlanarContext *__pyx_v_context; int __pyx_v_drawing; int __pyx_v_first; - long __pyx_v_last; + int __pyx_v_last; PyObject *__pyx_v_r = NULL; PyObject *__pyx_v_nodes = NULL; - long __pyx_v_n; + int __pyx_v_n; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - long __pyx_t_2; - long __pyx_t_3; - long __pyx_t_4; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; @@ -4862,43 +4868,43 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct /* "planarity/classic/planarity.pyx":109 * - * def nodes(self,data=False): + * def nodes(self, data=False): * DRAWPLANAR_ID=1 # <<<<<<<<<<<<<< * cdef cplanarity.DrawPlanarContext *context - * drawing=cplanarity.gp_FindExtension(self.theGraph, + * */ __pyx_v_DRAWPLANAR_ID = 1; - /* "planarity/classic/planarity.pyx":111 - * DRAWPLANAR_ID=1 + /* "planarity/classic/planarity.pyx":112 * cdef cplanarity.DrawPlanarContext *context + * * drawing=cplanarity.gp_FindExtension(self.theGraph, # <<<<<<<<<<<<<< * DRAWPLANAR_ID, - * &context) + * &context) */ - __pyx_v_drawing = gp_FindExtension(__pyx_v_self->theGraph, __pyx_v_DRAWPLANAR_ID, ((void *)(&__pyx_v_context))); + __pyx_v_drawing = gp_FindExtension(__pyx_v_self->theGraph, __pyx_v_DRAWPLANAR_ID, ((void **)(&__pyx_v_context))); - /* "planarity/classic/planarity.pyx":115 - * &context) + /* "planarity/classic/planarity.pyx":116 + * &context) * - * first=cplanarity.gp_GetFirstVertex(self.theGraph) # <<<<<<<<<<<<<< - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) # <<<<<<<<<<<<<< + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * r=self.reverse_nodemap */ - __pyx_v_first = gp_GetFirstVertex(__pyx_v_self->theGraph); + __pyx_v_first = gp_LowerBoundVertices(__pyx_v_self->theGraph); - /* "planarity/classic/planarity.pyx":116 + /* "planarity/classic/planarity.pyx":117 * - * first=cplanarity.gp_GetFirstVertex(self.theGraph) - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 # <<<<<<<<<<<<<< + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) # <<<<<<<<<<<<<< * r=self.reverse_nodemap * nodes=[] */ - __pyx_v_last = (gp_GetLastVertex(__pyx_v_self->theGraph) + 1); + __pyx_v_last = gp_UpperBoundVertices(__pyx_v_self->theGraph); - /* "planarity/classic/planarity.pyx":117 - * first=cplanarity.gp_GetFirstVertex(self.theGraph) - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + /* "planarity/classic/planarity.pyx":118 + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * r=self.reverse_nodemap # <<<<<<<<<<<<<< * nodes=[] * for n in range(first,last): @@ -4908,19 +4914,19 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct __pyx_v_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":118 - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + /* "planarity/classic/planarity.pyx":119 + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * r=self.reverse_nodemap * nodes=[] # <<<<<<<<<<<<<< * for n in range(first,last): * if data: */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_nodes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":119 + /* "planarity/classic/planarity.pyx":120 * r=self.reverse_nodemap * nodes=[] * for n in range(first,last): # <<<<<<<<<<<<<< @@ -4932,29 +4938,29 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct for (__pyx_t_4 = __pyx_v_first; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_n = __pyx_t_4; - /* "planarity/classic/planarity.pyx":120 + /* "planarity/classic/planarity.pyx":121 * nodes=[] * for n in range(first,last): * if data: # <<<<<<<<<<<<<< * data={} * if drawing==1: */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_data); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_data); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 121, __pyx_L1_error) if (__pyx_t_5) { - /* "planarity/classic/planarity.pyx":121 + /* "planarity/classic/planarity.pyx":122 * for n in range(first,last): * if data: * data={} # <<<<<<<<<<<<<< * if drawing==1: * data.update(pos=context.VI[n].pos, */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":122 + /* "planarity/classic/planarity.pyx":123 * if data: * data={} * if drawing==1: # <<<<<<<<<<<<<< @@ -4964,7 +4970,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct __pyx_t_5 = (__pyx_v_drawing == 1); if (__pyx_t_5) { - /* "planarity/classic/planarity.pyx":123 + /* "planarity/classic/planarity.pyx":124 * data={} * if drawing==1: * data.update(pos=context.VI[n].pos, # <<<<<<<<<<<<<< @@ -4973,48 +4979,48 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct */ __pyx_t_6 = __pyx_v_data; __Pyx_INCREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).pos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).pos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "planarity/classic/planarity.pyx":124 + /* "planarity/classic/planarity.pyx":125 * if drawing==1: * data.update(pos=context.VI[n].pos, * start=context.VI[n].start, # <<<<<<<<<<<<<< * end=context.VI[n].end) * nodes.append((r[n],data)) */ - __pyx_t_8 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).start); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).start); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - /* "planarity/classic/planarity.pyx":125 + /* "planarity/classic/planarity.pyx":126 * data.update(pos=context.VI[n].pos, * start=context.VI[n].start, * end=context.VI[n].end) # <<<<<<<<<<<<<< * nodes.append((r[n],data)) * else: */ - __pyx_t_9 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).end); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 125, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyLong_From_int((__pyx_v_context->VI[__pyx_v_n]).end); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = 0; { PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, NULL}; - __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_pos, __pyx_t_7, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 123, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start, __pyx_t_8, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 123, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_end, __pyx_t_9, __pyx_t_11, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 123, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_pos, __pyx_t_7, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 124, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start, __pyx_t_8, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 124, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_end, __pyx_t_9, __pyx_t_11, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 124, __pyx_L1_error) __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_update, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":122 + /* "planarity/classic/planarity.pyx":123 * if data: * data={} * if drawing==1: # <<<<<<<<<<<<<< @@ -5023,7 +5029,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct */ } - /* "planarity/classic/planarity.pyx":126 + /* "planarity/classic/planarity.pyx":127 * start=context.VI[n].start, * end=context.VI[n].end) * nodes.append((r[n],data)) # <<<<<<<<<<<<<< @@ -5032,25 +5038,25 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct */ if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 126, __pyx_L1_error) + __PYX_ERR(0, 127, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11) != (0)) __PYX_ERR(0, 126, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11) != (0)) __PYX_ERR(0, 127, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_data) != (0)) __PYX_ERR(0, 126, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_data) != (0)) __PYX_ERR(0, 127, __pyx_L1_error); __pyx_t_11 = 0; - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_nodes, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_nodes, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":120 + /* "planarity/classic/planarity.pyx":121 * nodes=[] * for n in range(first,last): * if data: # <<<<<<<<<<<<<< @@ -5060,7 +5066,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct goto __pyx_L5; } - /* "planarity/classic/planarity.pyx":128 + /* "planarity/classic/planarity.pyx":129 * nodes.append((r[n],data)) * else: * nodes.append((r[n])) # <<<<<<<<<<<<<< @@ -5070,20 +5076,20 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct /*else*/ { if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 128, __pyx_L1_error) + __PYX_ERR(0, 129, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_nodes, __pyx_t_11); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_nodes, __pyx_t_11); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_L5:; } - /* "planarity/classic/planarity.pyx":129 + /* "planarity/classic/planarity.pyx":130 * else: * nodes.append((r[n])) * return nodes # <<<<<<<<<<<<<< @@ -5098,7 +5104,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct /* "planarity/classic/planarity.pyx":108 * * - * def nodes(self,data=False): # <<<<<<<<<<<<<< + * def nodes(self, data=False): # <<<<<<<<<<<<<< * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context */ @@ -5122,7 +5128,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_12nodes(struct return __pyx_r; } -/* "planarity/classic/planarity.pyx":132 +/* "planarity/classic/planarity.pyx":133 * * * def edges(self,data=False): # <<<<<<<<<<<<<< @@ -5170,24 +5176,24 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_data,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 132, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 133, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 132, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 133, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "edges", 0) < (0)) __PYX_ERR(0, 132, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "edges", 0) < (0)) __PYX_ERR(0, 133, __pyx_L3_error) if (!values[0]) values[0] = __Pyx_NewRef(((PyObject *)Py_False)); } else { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 132, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 133, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; @@ -5198,7 +5204,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("edges", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 132, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("edges", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 133, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5226,17 +5232,17 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct PyObject *__pyx_v_edges = NULL; PyObject *__pyx_v_r = NULL; int __pyx_v_first; - long __pyx_v_last; - long __pyx_v_n; + int __pyx_v_last; + int __pyx_v_n; int __pyx_v_e; int __pyx_v_is_edge; int __pyx_v_nbr; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - long __pyx_t_2; - long __pyx_t_3; - long __pyx_t_4; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; @@ -5251,7 +5257,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct __Pyx_RefNannySetupContext("edges", 0); __Pyx_INCREF(__pyx_v_data); - /* "planarity/classic/planarity.pyx":133 + /* "planarity/classic/planarity.pyx":134 * * def edges(self,data=False): * DRAWPLANAR_ID=1 # <<<<<<<<<<<<<< @@ -5260,60 +5266,60 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_v_DRAWPLANAR_ID = 1; - /* "planarity/classic/planarity.pyx":135 + /* "planarity/classic/planarity.pyx":136 * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context * drawing=cplanarity.gp_FindExtension(self.theGraph, # <<<<<<<<<<<<<< * DRAWPLANAR_ID, - * &context) + * &context) */ - __pyx_v_drawing = gp_FindExtension(__pyx_v_self->theGraph, __pyx_v_DRAWPLANAR_ID, ((void *)(&__pyx_v_context))); + __pyx_v_drawing = gp_FindExtension(__pyx_v_self->theGraph, __pyx_v_DRAWPLANAR_ID, ((void **)(&__pyx_v_context))); - /* "planarity/classic/planarity.pyx":138 + /* "planarity/classic/planarity.pyx":139 * DRAWPLANAR_ID, - * &context) + * &context) * edges=[] # <<<<<<<<<<<<<< * r=self.reverse_nodemap - * first=cplanarity.gp_GetFirstVertex(self.theGraph) + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_edges = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":139 - * &context) + /* "planarity/classic/planarity.pyx":140 + * &context) * edges=[] * r=self.reverse_nodemap # <<<<<<<<<<<<<< - * first=cplanarity.gp_GetFirstVertex(self.theGraph) - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) */ __pyx_t_1 = __pyx_v_self->reverse_nodemap; __Pyx_INCREF(__pyx_t_1); __pyx_v_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":140 + /* "planarity/classic/planarity.pyx":141 * edges=[] * r=self.reverse_nodemap - * first=cplanarity.gp_GetFirstVertex(self.theGraph) # <<<<<<<<<<<<<< - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) # <<<<<<<<<<<<<< + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * for n in range(first,last): */ - __pyx_v_first = gp_GetFirstVertex(__pyx_v_self->theGraph); + __pyx_v_first = gp_LowerBoundVertices(__pyx_v_self->theGraph); - /* "planarity/classic/planarity.pyx":141 + /* "planarity/classic/planarity.pyx":142 * r=self.reverse_nodemap - * first=cplanarity.gp_GetFirstVertex(self.theGraph) - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 # <<<<<<<<<<<<<< + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) # <<<<<<<<<<<<<< * for n in range(first,last): * e=cplanarity.gp_GetFirstEdge(self.theGraph,n) */ - __pyx_v_last = (gp_GetLastVertex(__pyx_v_self->theGraph) + 1); + __pyx_v_last = gp_UpperBoundVertices(__pyx_v_self->theGraph); - /* "planarity/classic/planarity.pyx":142 - * first=cplanarity.gp_GetFirstVertex(self.theGraph) - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + /* "planarity/classic/planarity.pyx":143 + * first=cplanarity.gp_LowerBoundVertices(self.theGraph) + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * for n in range(first,last): # <<<<<<<<<<<<<< * e=cplanarity.gp_GetFirstEdge(self.theGraph,n) * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) @@ -5323,8 +5329,8 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct for (__pyx_t_4 = __pyx_v_first; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_n = __pyx_t_4; - /* "planarity/classic/planarity.pyx":143 - * last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + /* "planarity/classic/planarity.pyx":144 + * last=cplanarity.gp_UpperBoundVertices(self.theGraph) * for n in range(first,last): * e=cplanarity.gp_GetFirstEdge(self.theGraph,n) # <<<<<<<<<<<<<< * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) @@ -5332,7 +5338,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_v_e = gp_GetFirstEdge(__pyx_v_self->theGraph, __pyx_v_n); - /* "planarity/classic/planarity.pyx":144 + /* "planarity/classic/planarity.pyx":145 * for n in range(first,last): * e=cplanarity.gp_GetFirstEdge(self.theGraph,n) * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) # <<<<<<<<<<<<<< @@ -5341,7 +5347,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_v_is_edge = gp_IsEdge(__pyx_v_self->theGraph, __pyx_v_e); - /* "planarity/classic/planarity.pyx":145 + /* "planarity/classic/planarity.pyx":146 * e=cplanarity.gp_GetFirstEdge(self.theGraph,n) * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) * while is_edge > 0: # <<<<<<<<<<<<<< @@ -5352,7 +5358,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct __pyx_t_5 = (__pyx_v_is_edge > 0); if (!__pyx_t_5) break; - /* "planarity/classic/planarity.pyx":146 + /* "planarity/classic/planarity.pyx":147 * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) * while is_edge > 0: * nbr=cplanarity.gp_GetNeighbor(self.theGraph,e) # <<<<<<<<<<<<<< @@ -5361,7 +5367,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_v_nbr = gp_GetNeighbor(__pyx_v_self->theGraph, __pyx_v_e); - /* "planarity/classic/planarity.pyx":147 + /* "planarity/classic/planarity.pyx":148 * while is_edge > 0: * nbr=cplanarity.gp_GetNeighbor(self.theGraph,e) * if nbr > n: # <<<<<<<<<<<<<< @@ -5371,29 +5377,29 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct __pyx_t_5 = (__pyx_v_nbr > __pyx_v_n); if (__pyx_t_5) { - /* "planarity/classic/planarity.pyx":148 + /* "planarity/classic/planarity.pyx":149 * nbr=cplanarity.gp_GetNeighbor(self.theGraph,e) * if nbr > n: * if data: # <<<<<<<<<<<<<< * data={} * if drawing==1: */ - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_data); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_data); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 149, __pyx_L1_error) if (__pyx_t_5) { - /* "planarity/classic/planarity.pyx":149 + /* "planarity/classic/planarity.pyx":150 * if nbr > n: * if data: * data={} # <<<<<<<<<<<<<< * if drawing==1: * data.update(pos=context.E[e].pos, */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":150 + /* "planarity/classic/planarity.pyx":151 * if data: * data={} * if drawing==1: # <<<<<<<<<<<<<< @@ -5403,7 +5409,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct __pyx_t_5 = (__pyx_v_drawing == 1); if (__pyx_t_5) { - /* "planarity/classic/planarity.pyx":151 + /* "planarity/classic/planarity.pyx":152 * data={} * if drawing==1: * data.update(pos=context.E[e].pos, # <<<<<<<<<<<<<< @@ -5412,48 +5418,48 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_t_6 = __pyx_v_data; __Pyx_INCREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).pos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).pos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "planarity/classic/planarity.pyx":152 + /* "planarity/classic/planarity.pyx":153 * if drawing==1: * data.update(pos=context.E[e].pos, * start=context.E[e].start, # <<<<<<<<<<<<<< * end=context.E[e].end) * edges.append((r[n],r[nbr],data)) */ - __pyx_t_8 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).start); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 152, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).start); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - /* "planarity/classic/planarity.pyx":153 + /* "planarity/classic/planarity.pyx":154 * data.update(pos=context.E[e].pos, * start=context.E[e].start, * end=context.E[e].end) # <<<<<<<<<<<<<< * edges.append((r[n],r[nbr],data)) * else: */ - __pyx_t_9 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).end); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyLong_From_int((__pyx_v_context->E[__pyx_v_e]).end); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = 0; { PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, NULL}; - __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_pos, __pyx_t_7, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 151, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start, __pyx_t_8, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 151, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_end, __pyx_t_9, __pyx_t_11, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 151, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_pos, __pyx_t_7, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 152, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start, __pyx_t_8, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 152, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_end, __pyx_t_9, __pyx_t_11, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 152, __pyx_L1_error) __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_update, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":150 + /* "planarity/classic/planarity.pyx":151 * if data: * data={} * if drawing==1: # <<<<<<<<<<<<<< @@ -5462,7 +5468,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ } - /* "planarity/classic/planarity.pyx":154 + /* "planarity/classic/planarity.pyx":155 * start=context.E[e].start, * end=context.E[e].end) * edges.append((r[n],r[nbr],data)) # <<<<<<<<<<<<<< @@ -5471,37 +5477,37 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 154, __pyx_L1_error) + __PYX_ERR(0, 155, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 154, __pyx_L1_error) + __PYX_ERR(0, 155, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_nbr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_nbr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_11); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11) != (0)) __PYX_ERR(0, 154, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11) != (0)) __PYX_ERR(0, 155, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 154, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 155, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_data) != (0)) __PYX_ERR(0, 154, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_data) != (0)) __PYX_ERR(0, 155, __pyx_L1_error); __pyx_t_11 = 0; __pyx_t_9 = 0; - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_edges, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_edges, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":148 + /* "planarity/classic/planarity.pyx":149 * nbr=cplanarity.gp_GetNeighbor(self.theGraph,e) * if nbr > n: * if data: # <<<<<<<<<<<<<< @@ -5511,7 +5517,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct goto __pyx_L8; } - /* "planarity/classic/planarity.pyx":156 + /* "planarity/classic/planarity.pyx":157 * edges.append((r[n],r[nbr],data)) * else: * edges.append((r[n],r[nbr])) # <<<<<<<<<<<<<< @@ -5521,36 +5527,36 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct /*else*/ { if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 156, __pyx_L1_error) + __PYX_ERR(0, 157, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_long(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v_r == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 156, __pyx_L1_error) + __PYX_ERR(0, 157, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_nbr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_nbr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_r, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9) != (0)) __PYX_ERR(0, 156, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9) != (0)) __PYX_ERR(0, 157, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_11); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11) != (0)) __PYX_ERR(0, 156, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11) != (0)) __PYX_ERR(0, 157, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_11 = 0; - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_edges, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_edges, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L8:; - /* "planarity/classic/planarity.pyx":147 + /* "planarity/classic/planarity.pyx":148 * while is_edge > 0: * nbr=cplanarity.gp_GetNeighbor(self.theGraph,e) * if nbr > n: # <<<<<<<<<<<<<< @@ -5559,7 +5565,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ } - /* "planarity/classic/planarity.pyx":157 + /* "planarity/classic/planarity.pyx":158 * else: * edges.append((r[n],r[nbr])) * e=cplanarity.gp_GetNextEdge(self.theGraph,e) # <<<<<<<<<<<<<< @@ -5568,7 +5574,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct */ __pyx_v_e = gp_GetNextEdge(__pyx_v_self->theGraph, __pyx_v_e); - /* "planarity/classic/planarity.pyx":158 + /* "planarity/classic/planarity.pyx":159 * edges.append((r[n],r[nbr])) * e=cplanarity.gp_GetNextEdge(self.theGraph,e) * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) # <<<<<<<<<<<<<< @@ -5579,7 +5585,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct } } - /* "planarity/classic/planarity.pyx":159 + /* "planarity/classic/planarity.pyx":160 * e=cplanarity.gp_GetNextEdge(self.theGraph,e) * is_edge=cplanarity.gp_IsEdge(self.theGraph, e) * return edges # <<<<<<<<<<<<<< @@ -5591,7 +5597,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct __pyx_r = __pyx_v_edges; goto __pyx_L0; - /* "planarity/classic/planarity.pyx":132 + /* "planarity/classic/planarity.pyx":133 * * * def edges(self,data=False): # <<<<<<<<<<<<<< @@ -5618,7 +5624,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_14edges(struct return __pyx_r; } -/* "planarity/classic/planarity.pyx":162 +/* "planarity/classic/planarity.pyx":163 * * * def ascii(self): # <<<<<<<<<<<<<< @@ -5683,7 +5689,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct int __pyx_clineno = 0; __Pyx_RefNannySetupContext("ascii", 0); - /* "planarity/classic/planarity.pyx":163 + /* "planarity/classic/planarity.pyx":164 * * def ascii(self): * cdef char* s = NULL # <<<<<<<<<<<<<< @@ -5692,7 +5698,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct */ __pyx_v_s = NULL; - /* "planarity/classic/planarity.pyx":164 + /* "planarity/classic/planarity.pyx":165 * def ascii(self): * cdef char* s = NULL * self.embed_drawplanar() # <<<<<<<<<<<<<< @@ -5706,12 +5712,12 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_embed_drawplanar, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":165 + /* "planarity/classic/planarity.pyx":166 * cdef char* s = NULL * self.embed_drawplanar() * status = cplanarity.gp_DrawPlanar_RenderToString(self.theGraph, &s) # <<<<<<<<<<<<<< @@ -5720,19 +5726,19 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct */ __pyx_v_status = gp_DrawPlanar_RenderToString(__pyx_v_self->theGraph, (&__pyx_v_s)); - /* "planarity/classic/planarity.pyx":166 + /* "planarity/classic/planarity.pyx":167 * self.embed_drawplanar() * status = cplanarity.gp_DrawPlanar_RenderToString(self.theGraph, &s) * py_bytes = s[:] # <<<<<<<<<<<<<< * free(s) * return py_bytes.decode('ascii') */ - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_s + 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_s + 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_py_bytes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":167 + /* "planarity/classic/planarity.pyx":168 * status = cplanarity.gp_DrawPlanar_RenderToString(self.theGraph, &s) * py_bytes = s[:] * free(s) # <<<<<<<<<<<<<< @@ -5741,7 +5747,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct */ free(__pyx_v_s); - /* "planarity/classic/planarity.pyx":168 + /* "planarity/classic/planarity.pyx":169 * py_bytes = s[:] * free(s) * return py_bytes.decode('ascii') # <<<<<<<<<<<<<< @@ -5749,13 +5755,13 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/classic/planarity.pyx":162 + /* "planarity/classic/planarity.pyx":163 * * * def ascii(self): # <<<<<<<<<<<<<< @@ -5776,7 +5782,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_16ascii(struct return __pyx_r; } -/* "planarity/classic/planarity.pyx":171 +/* "planarity/classic/planarity.pyx":172 * * * def write(self,path): # <<<<<<<<<<<<<< @@ -5824,32 +5830,32 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_path,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 171, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 172, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 171, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 172, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write", 0) < (0)) __PYX_ERR(0, 171, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write", 0) < (0)) __PYX_ERR(0, 172, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, i); __PYX_ERR(0, 171, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, i); __PYX_ERR(0, 172, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 171, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 172, __pyx_L3_error) } __pyx_v_path = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 171, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 172, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5884,7 +5890,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_18write(struct int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write", 0); - /* "planarity/classic/planarity.pyx":172 + /* "planarity/classic/planarity.pyx":173 * * def write(self,path): * bpath=path.encode() # <<<<<<<<<<<<<< @@ -5898,22 +5904,22 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_18write(struct PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_v_bpath = __pyx_t_1; __pyx_t_1 = 0; - /* "planarity/classic/planarity.pyx":173 + /* "planarity/classic/planarity.pyx":174 * def write(self,path): * bpath=path.encode() * status=cplanarity.gp_Write(self.theGraph, bpath, # <<<<<<<<<<<<<< * cplanarity.WRITE_ADJLIST) * */ - __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_bpath); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_bpath); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 174, __pyx_L1_error) - /* "planarity/classic/planarity.pyx":174 + /* "planarity/classic/planarity.pyx":175 * bpath=path.encode() * status=cplanarity.gp_Write(self.theGraph, bpath, * cplanarity.WRITE_ADJLIST) # <<<<<<<<<<<<<< @@ -5922,7 +5928,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_18write(struct */ __pyx_v_status = gp_Write(__pyx_v_self->theGraph, __pyx_t_4, WRITE_ADJLIST); - /* "planarity/classic/planarity.pyx":171 + /* "planarity/classic/planarity.pyx":172 * * * def write(self,path): # <<<<<<<<<<<<<< @@ -5945,7 +5951,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_18write(struct return __pyx_r; } -/* "planarity/classic/planarity.pyx":176 +/* "planarity/classic/planarity.pyx":177 * cplanarity.WRITE_ADJLIST) * * def mapping(self): # <<<<<<<<<<<<<< @@ -6000,7 +6006,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_20mapping(struc __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mapping", 0); - /* "planarity/classic/planarity.pyx":177 + /* "planarity/classic/planarity.pyx":178 * * def mapping(self): * return self.reverse_nodemap # <<<<<<<<<<<<<< @@ -6010,7 +6016,7 @@ static PyObject *__pyx_pf_9planarity_7classic_9planarity_6PGraph_20mapping(struc __pyx_r = __pyx_v_self->reverse_nodemap; goto __pyx_L0; - /* "planarity/classic/planarity.pyx":176 + /* "planarity/classic/planarity.pyx":177 * cplanarity.WRITE_ADJLIST) * * def mapping(self): # <<<<<<<<<<<<<< @@ -6818,7 +6824,7 @@ __Pyx_RefNannySetupContext("PyInit_planarity", 0); * * def embed_drawplanar(self): # <<<<<<<<<<<<<< * status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - * if status == cplanarity.NOTOK: + * if status != cplanarity.OK: */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_7embed_drawplanar, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_embed_drawplanar, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -6861,7 +6867,7 @@ __Pyx_RefNannySetupContext("PyInit_planarity", 0); /* "planarity/classic/planarity.pyx":108 * * - * def nodes(self,data=False): # <<<<<<<<<<<<<< + * def nodes(self, data=False): # <<<<<<<<<<<<<< * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context */ @@ -6874,64 +6880,64 @@ __Pyx_RefNannySetupContext("PyInit_planarity", 0); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_nodes, __pyx_t_2) < (0)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/classic/planarity.pyx":132 + /* "planarity/classic/planarity.pyx":133 * * * def edges(self,data=False): # <<<<<<<<<<<<<< * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_15edges, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_edges, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_15edges, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_edges, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[0]); - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_edges, __pyx_t_2) < (0)) __PYX_ERR(0, 132, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_edges, __pyx_t_2) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/classic/planarity.pyx":162 + /* "planarity/classic/planarity.pyx":163 * * * def ascii(self): # <<<<<<<<<<<<<< * cdef char* s = NULL * self.embed_drawplanar() */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_17ascii, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_ascii, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_17ascii, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_ascii, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_ascii, __pyx_t_2) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_ascii, __pyx_t_2) < (0)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/classic/planarity.pyx":171 + /* "planarity/classic/planarity.pyx":172 * * * def write(self,path): # <<<<<<<<<<<<<< * bpath=path.encode() * status=cplanarity.gp_Write(self.theGraph, bpath, */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_19write, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_write, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_19write, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_write, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_write, __pyx_t_2) < (0)) __PYX_ERR(0, 171, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_write, __pyx_t_2) < (0)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/classic/planarity.pyx":176 + /* "planarity/classic/planarity.pyx":177 * cplanarity.WRITE_ADJLIST) * * def mapping(self): # <<<<<<<<<<<<<< * return self.reverse_nodemap */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_21mapping, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_mapping, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_7classic_9planarity_6PGraph_21mapping, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PGraph_mapping, NULL, __pyx_mstate_global->__pyx_n_u_planarity_classic_planarity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_mapping, __pyx_t_2) < (0)) __PYX_ERR(0, 176, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_7classic_9planarity_PGraph, __pyx_mstate_global->__pyx_n_u_mapping, __pyx_t_2) < (0)) __PYX_ERR(0, 177, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 @@ -7030,7 +7036,7 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { /* "planarity/classic/planarity.pyx":108 * * - * def nodes(self,data=False): # <<<<<<<<<<<<<< + * def nodes(self, data=False): # <<<<<<<<<<<<<< * DRAWPLANAR_ID=1 * cdef cplanarity.DrawPlanarContext *context */ @@ -7067,33 +7073,33 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { - const struct { const unsigned int length: 9; } index[] = {{1},{18},{1},{7},{6},{2},{23},{9},{25},{31},{30},{60},{61},{37},{28},{65},{14},{13},{6},{24},{26},{12},{12},{23},{19},{16},{23},{14},{12},{12},{20},{5},{18},{5},{18},{7},{4},{7},{1},{5},{16},{12},{6},{3},{6},{5},{8},{12},{5},{13},{7},{9},{5},{4},{16},{4},{8},{7},{10},{1},{8},{3},{5},{4},{27},{3},{3},{8},{11},{12},{1},{10},{17},{13},{1},{4},{12},{10},{12},{19},{5},{6},{8},{6},{6},{4},{8},{5},{3},{73},{72},{47},{30},{27},{56},{9},{9},{182},{278}}; - #if (CYTHON_COMPRESS_STRINGS) == 3 && __PYX_LIMITED_VERSION_HEX >= 0x030e0000 /* compression: zstd (1053 bytes) */ -const char* const cstring = "(\265/\375`f\006\235 \000\266s\2578\020\265\016\000D\002A\000@\301\025\210\232\nDM\005\024\010\204\373aE\322\356\344\377\310feR2nb\246=F\302\247\346\360\370\t\362\022C\226\031\005\214\005\233\213LK\003\226\000\223\000\251\0003,\224k5)n\276M`\031\2072\213GO\213/\217\333\253\343\022\275,\306\370M\306\253\\\337\235,Z\357\272r\265,7\306Q\257\360n\024\027\363\345\301a\305\034g\\\253\032\334W\223\334\222\232o\317\213q\\\363bc\3250\017\314\227\333\256'r\024\010V\017\327\227\3556\242<,\336\273\206\326\003\245E\255\257Wr\343X\327\\\303\021\334\330\2730\360z\341\r\303\252\353\350\3012\326b\206a\013\313\367\206\256\2721\230r\307\033\36789f\354\345\232\230e\331\246#\266KuXI\332H\351\276\374\346\242\267q\213\343(\216(\355\232\325\034\222\240Hi\306uV\303}\273\262=\273\034oL7\246\024Fm&_\224\362\255\361\013\314\327\346{+\257 \317\242\225\331\352\272\266jN3\246\241\215\361:\272\366\315\230\223\242\026-J\3046\337v}\335\031n\2730\224[\314\262\335.\307\272\006\212y\034\353\214b\331\256\211\274jR\2661\005\257k\2661\266\273\362\3127\277\233RK\257%\301\253)E\311\260Z\350\314\007\363\271\310\334|\001\037\344\223*y\255\264\265p\337W\376\200~rr\0139Pn\244\325%J\007T\307?\235=\017\375\001\243\004q\0078\204\020\310\237\364\202\222\365\202\023\205v\273\224y{\253\357\224*\377\322M%\311\340\247J\005\321'u\236\225\310'\2355\376\363$f\205H'\002\345Xg\352\004\331\031\210~\253W\364\036\234\352\363\241\231*\363dR$\214\254>\311\327\230\237I\322i\275v\2162A\364i\275\243\\\341\nB\237\224\2539\277Se\322\231B\377\363\0311O\326\265\266/\031\326\235\313+8\222\227S\272IMyH\326\327\0057\245\0014\034B\350\1779\223\206I1\"\210\351\021\243\337\332\235N\033\377\005TS\305\274\341\310\370\247\034\300\314\t\363\250\014\327\307\311\342\005<\315\0340\275\210\377\231\024\346\252\233J\245\005\235\3238A\337\362b\237\030e\344\350\364\t\321\007\005\230*\375\306\302\373\2513\341\004\2354\036f^x\332W\017\342YL\001\223\326\007zi\341\177\235\242\257J\205\321o\225\014\243/\372\265d(Wj\305Y\340\010h'\216_\360 \237\341\240\243y""\225?y\215\222\256t\266\316\020\216\337\301\361A'\313\247\374\006\204\016\"\264\253eC/\t\350Z\345\006\216@ \200\230\250Q\245bH\321\004B\244\244\205B\007 \204\030\306\354:\"\272(\345\2205fH\202!M=J\315\001\206R\213\301w0\202\366\247B\272x5\366\370\035\023\001]\313b#\021H\016Q\006\033\034@R\302\265\305\313:\014\007\206\225\222\003jQT\004\266\210!\207\347\321\257\344\231a\325\242^\2105\230\346\031\025\022Bky\353\244\346\334\001\271\rO\336g\276\205\263\3227\310\263\254u`\224\006'P`\344\324\365\233o\243J\250\002\266\221\272`!G\221\231Q \244K}O\002Z\352`q\014\357\027\370\302\315\266$\2675\225\277\333\021\341\033H\272\247\221\240E\"\330\203T6\211\221\346LHQ\202\234|\356\246\000\337X5\300(S\334b\355U\327b\363\377So\273\262\016\017\310[f\025\201q\200)\303\324'\364W/\350f/\343\203\016\222\014\025\032\271h*\032\340\3576]l\267\221\346\360\177\"\270\022\345\232} \222\214\354\004\365U\006\366\366Q\323\357\004)\341\235fvg:\372\255m\324I7\034\020+\324sFE\001\361\372rc\0172j\002*\217\350\035\000\252N\345\375\333R\265\014\203(f\267\2662\360v\313\246@\233\377\037\350E'\255\277@\270\032"; - PyObject *data = __Pyx_DecompressString(cstring, 1053, 3); + const struct { const unsigned int length: 9; } index[] = {{1},{18},{1},{7},{6},{2},{23},{9},{25},{31},{30},{60},{61},{37},{28},{65},{14},{13},{6},{24},{26},{12},{12},{23},{19},{16},{23},{14},{12},{12},{20},{5},{18},{5},{18},{7},{4},{7},{1},{5},{16},{12},{6},{3},{6},{5},{8},{12},{5},{13},{7},{9},{5},{4},{16},{4},{8},{7},{10},{1},{8},{3},{5},{4},{27},{3},{3},{8},{11},{12},{1},{10},{17},{13},{1},{4},{12},{10},{12},{19},{5},{6},{8},{6},{6},{4},{8},{5},{3},{73},{72},{47},{30},{27},{56},{9},{9},{274},{180}}; + #if (CYTHON_COMPRESS_STRINGS) == 3 && __PYX_LIMITED_VERSION_HEX >= 0x030e0000 /* compression: zstd (1070 bytes) */ +const char* const cstring = "(\265/\375``\006%!\000\246\264\263;0\223\033\300\020\201\272\241\252\021\036h\240\240\002\206\364\212\221+H#\231\222&O\227TRv\222$%\363\363\020a\322i\r]I\336.F\373\375o\334}\204x\204BH:\305f\001\230\000\224\000\256\000049`\rK%cn\222\335w\024q\3531\206u\351q\362\345y\234y\\\244\267I\230\257\321x\327\363\354\263I\354e\327\276\330%\303\374\367\032s\377<\271\363\217\036\257\366z\353\331\345a\317\334\364\330\344\276{\036\314\353\231\007+/\027\275pgO\313\036\351\2770\274\236\276/Z\255\374@\260\356\375\216\030\344\343$\347\331;\251y\315\357\276c\031v\355e1\314\336\230\307\361\362[z\342\326\234\334\242\306\342\316yt\335\256\303\225\\\326\274\347\315rko\317\310\035\3338\251\326\322\262\345\3435e\245\265=\373\232\313\326\312N\226%Y~\334\325s\267\265y4C\322\332\255o\317\035{-\307zO\366\272k\333\265\265\242\305\333|Y\353;\327\257pg\274s\276\376\206~\2238\206\257+\343\313\275\335\332\216\030\346o\351\352yko\222\234\304\037\251\361\256\365\373\3125\236\226e\254\307\232E\253e\257\371,$\267\270uY\336\036\253c}F\372\313\315X\3276\314\256\236\2565\356\327_\337}\356\326b\233\261\031fn\355G\303z\2615\240\014\030\255\323\303f Z\273 \325\351g'\255e\003\301S\250\023\332\2719\334\272[I\353W\234\021_jE\251@\022_b\343\014m\t6\205Q\227\246\374\203\223\025c#\215r9\025\232\177\353\373\234#i\314?\235%\204Uu6\220\326\322\377Y\221\254%\365&\005S\023\024\203\204#u7\226\252REr\010\244\265\3651>\220m\004\014\222\241#(\n\275`(Y\255\245\364\006\005Q\223/\373\367\177\234\014\244U\366S\347\312v0ZK\267\033\025TGN\270\323h\005\203J\375\263\371\235\365l\216\327'\373\033\226f\366\326v\223[?\232\367\225\303\0362\233\302h\355\004P\226\237\223\3411\250\235j\223\212\250\206\307ER\027T\204\312>\30179\254Z\347\303\302\232;\025\000\014\014\225\276\204\010\007\336N\035\350\305\202\301\314\247XX[9\224\212\223\202\002\027eAs>8V\324-\340&SkT1\3758\\jK\rQ]RQ*C\tP\217b\005\321\013t\365O&\223\003\277u\220\337ba\005\377\305\347\350n;<\337\202\244\223:\244]\312AZ\357\371p\266\240\3240m\245\251\010\234J\365\351M?\023\316""\224a3\030\255W\246^\225\344cM}\254\235\312JU\251\307\004nb\224\273'\3047\211p\001\200\227\250\001!s\210!\n\244fI\013\2129 \204\030\246\314\354\302\351\\\352\220D4#2$\252\261\307\034\0220DK1\326\217X\267l\3512I\305\3212\360\013gl\222\271\260\265\201R\241\220\205\037_tW\001\242\367$sKa\341\272\323Qn\271\001\265z\257\326\000\205\240\237\362\265\236\321U\017\244\276\362\311\022A\n\021\204xT\206\234\211\353\326@7\342.C\242\314\334\220M\007\004!e\377a\\v\226\320\010c\247\017\2337\014+\344\000\273_\034a]V\236\301\214\020\361\027\361F\360\264|\240\243\031\225_\250\205\227\333\332]\373)O\332\\\010\013\310n\243\221\246qB\211\207\330\233F\321\rN\330r\202\244=~\246\252\337\240\037\314(%`1\340]ha\203\013N\235q:8c\341\352\004\300\001\320\206\365\235H\255\032\2727\004\203Y\016\026bD\321H\365\346dP\373\276\350D\270;\237\311\377\211\366\336)\033{\r\204\202G\251\272\331\230\tJ\353q\302.:\247a\324C\267!\337{:2L\0031\227>WUJ\355\267d!\036/T\206Q\331\004\340\002\327\345<\\\277\373\254\014J\020\211\326\255`\314!\330\372R\350\3027\034\244\223\023\223*\254\242\006"; + PyObject *data = __Pyx_DecompressString(cstring, 1070, 3); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #elif (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1151 bytes) */ -const char* const cstring = "BZh91AY&SY\270\315W\316\000\000\222\377\377|\337\377\377}\337\277\367\266\247\376\230\277\377\377\370@@@@@@@@\000@@@@\000P\003\376\343]\000\n\014 \224\222CA\240\323\304\312dh\321\240\r6\246\200\031\000\r\032h\323@h\32024a0\203PPM\352\236\247\220\232z\232\014G\240\021\204\311\2104h\006LL\021\223\t\220\321\210db\002P@\200Bm\001'\225?HM\000\310\001\2204\000\000\003@4a2h\364!\300\003M4\000\031\000\000\r\000\000\r\000\0002\000\001\241\240\004S\324F\200\023\000\000M\030\000\000\000\004d0\000\000& 3A\356\001\376\001\313\231\237\304\220a\200Ib\005\200\232(:\365\002\212,\223D\020\035\204\000\000D\004\004D\312d\251\220\360\301\"\250\225*\301\021\261a\025FH(h\266\313\324\272\306Q\244T\203\324\306\265X\021\n:ZH\264^b\223.X%\344k\222[\021\205N\rU\314\225YI\"\263\237\207\265\331\374\373\277\307\354\275\216\277je\002kB\220\213Q\247\334\2449^\201\010\036n\"@ \014\215\231\303\027\016\231\264j\217\333\024\340\375.o\035\306\035\203\260\216\265GI\274.\215@dM]\3565\355J\035\271{\267FV\033\020\312\302\346\024s\247\304D\212@\206C1$\226\257\225\205#\262H\023l\355\205\313\276\251h(\003=\340\241V)\013\242\030\034\300\302\357\212\210A\020`\237\240\004\241\023\320x\327\326\203mc\373\337\275\027B\376\235\231t\026\253\262\006\213\340\r\006\245\376T\343\225F\257\221\345QP\341\252\320\327c\035\365C\242i`\346\263\254U[;\262\347S\037\257\305y\275s\2346\264\203\2446\301\356\027k!5\224\225Y\020\251j]\r\005\273\271\n^\035\353\245\377r\324\236\222 g\210\2012\010r\250\211\337,\306\332\222\334\321AhV<\2306\233Q7\234g\003\304Qbl\3070t}T\327\216\312\216!\351\206\260\246\352\211<\364\365\267G\277e\322\311KH\003\314P4\352\267+\251\022(\232\373\r+j\034'\243N\377\006&\3743\344u7le\035\225W2\370#\005J\303!\223B\345X\354\013\333\036r\265\320m\245J\263\265\353w\031l\344\201B\270\326\343\276\272\222\n=\336cVO\215\370`D/$\324\265\010@eC\337\335$\222\304\344\333\262\325UDE\001gp\355\201\017#ZoB\334\2240\305\350s\337\014\205{\271\366g\330\266\316\244\254\255\221\013x\364\335\231\026E\217f\010\201\021\366g\n\222\271""\222\307:Mr\330\262\007Fl\016\001d\031\240=k$@Zt\"\204\221\014\253\312N\310s3g\300\245\344\265\003\307,\316\034\2109\243]R\201\0064\300b\263Uz\245\216?Y\t\201#17\202\315e\367\233\3534\300w\034<\344\254\316)q\363\231\036\325\357\034\242\373E\2723\303\216@ \037k\275l\234\203\3611\246[\334\211o\263:\377\320\233\321\016\216B\250G\t\361\241\221\312*\326(\307>\301\343\321\253\306+\321\367u\341\330iR&\333Xx\274\177\3352\2501q\212\227R\242\320A\2348\361\370*\236t\235\306\373\310\t1\001\306hS\351u\315Q\253\217\032\034'\331\251\035\023E\211xa\265\300WY\333\273\224/\220\264\347\2640\030\006.\2443P\343Z\241\364\026\2708\016ez\253\253g-jY\335\341\264Zx\305\363\026 o\302\342\r`9\212\202F1%Q\005\006\203\205\\\331\367y\332\007\352\310\3775\250NB V\361\002$\310{\224D\326Qe8\022\234oAdN4\034\031\314\350\232M\220\322m\203\313\354\306\033\234\264\315e\363\231\006\225Y\202Z0\020h\333\342\320\375ta\206)RL\r\021@\266\352v\031G\217D\315\346t)\3000G-\251\247\337a\246\252\3612\232/R\031I8\017\372\016R\220/\013\330M\363\014@Z\271:\005lu\314\024\023*\332\226`\246\255\253\211\212aK\006l\272\021\310k7\253H\226km.\020\002\321\025\235h\035\302\224:: \220W\232\263\337J\252\242\"\200\261\3023\252&\371s&\224)\305\"\253\032G\t\252\304O\243\205Ew\2551\300\223\223\271\020\247f\3348\321`P\324T\210\017\032\372\303\002O\022\0319\t#~\243\020\031\025n""\033@*uW\rI\212 \006z0A\024A|\353\tU6\326:\352%\276!p3\366\"m\352A\214\271\260Bbg\026\3148\234\272{\241e\231\004\004)\031Jv \220\267m\260\342\322TsM\024\2147\355\256Xv\315\214.\301\002\246\213i;\020\025\234\315=\n\241\034\256\365m\"\202)iX,\016\t\001\211J\351\225A3-\357\030\360\027\220\273@8Jb\201b22Y\355\002\327\031\327\014\271`7N\241x\273^\004\247\333f\036q\236q\277\263k\206y\234\225\022\r\201\320Z\256\227]\r\224\021r \201Z\261p\014F\204\240(\302>B\021]\234\247:\360\221\260\351j\303\300+\2656\334b\263e\027$\370\310\016L\2631\014\262QP\311@\206\3452a\372\037h,\013_#W\373pU\027v\223\266\204t3\346\236b\272\204ts\360\355\201!\r\264\275\234#\351\375\350x\022Ks\024\205$\375\362\237\031\307\234\317kr\017\376\t\003\311\233\376\323\330\030M\231\224E%'F\301\325\022\321P\222-\320\312\330\320v\202]\321\257h\207\351\021g\324\021\350\371\207\363\177\231H5>\305\231\2459d6\250\260\020\031\3028[\224\244\240R#\230\350\253\340\251\031\034\032iQH\223\230\265\212l^\020\033\246-~\342\317\025\325UVkJ1\232o\257\257\313\317\316\2427Q\330\035\021\246\232\264\201.6\014!\272\331\014\257\n\221^8\224Y',\342\r\027\212E\220\270f\214\031\235Z\\\230A\340\322iBN\232AXB4\177f\"\337\361w$S\205\t\017TUY\360"; + PyObject *data = __Pyx_DecompressString(cstring, 1145, 2); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1030 bytes) */ -const char* const cstring = "x\332\215SMo\333F\020\205\032\003\021l\245\265\035\247V\2424\240\235\2405\034[\201\032\265J\212~\200\201\n\243@\223Z\256\003\003\315a\261\"W\322F\324\222\332]Z\226s\361QG\036y\344q\217<\352'\344\250#\217\376)\235%eY\216\215\246\002(\356\316\307\2337o\206\273oY\227\271\003fP\346\371\322\220C\217\374fS\201\233\016!L\377\267-\332f.\247\254mx\230c\307!\216A\35461\250\310\002l\317\301\014s*\207?\031\027`\204s\227\227g\216g\226\203\205\240\326\263\231\245\354\rO\346\362Z\230\002\220\201m[\327\321\360\345\353^\351\032\344D\022f\033m\216\275\2161\240\262c\314\302\014!\271oI\237\023\361\177sm\216\007Y\350g\223)\243\222b\207\236\222\014`.(\003d\256\234r)\013\342\264\312\262C\366R\207\205\231\3665\211a\271\354\230p\231\001bc\177(;.3\334\346{bI\243\345r\303\243V\327\001\001~\0066\360\022\256\317-\362k\375\300<\332\377\323|c\036\240?\352\373)h\366_F\210\023\333\267\010\262R(\204fvA\244\220X^\363`aQ:=k\225\305\305\271\327$6\272\324\343\212\371\212\211\212\253\367\256\317\261t\007\242K\321<`\017{\036\2640\2751\327\236y\006\240\032\001B\303\023x\352\324\222\350\rL\346\200\264RnX\014\231E\335\262\345r\327\227\224\021\321\364\260\354X \013A\224!\311\261E\232\330\352\202\230\022\362l,\261\246\r\265HZ\377\323N\346[ \314\002\"\260\004\331*\264(\027\022\241\226\317,\004\277\366\205f(\235(\202Ng,\340\254\321g\315C\013=\321%C\361i\373\260\347\000\331\303@\025M5\200\203k\373\016\340\202\215\341\236>4y*\211n\355\362\223\230~$\227\013\350\271\236\347\no\210\232CI\004B\360\315\240)\305\276\217\235\014\213\317\266\000]\333\207\231\201\234\300N\350\275LWc\312\002N6\310\356;rna\320\r\313\0037\236\232| \001L \336\367@yr\214\035\237\210\001\346L?ze\323\351\236R\357\314L\362\245I\251\032\233\361\341x%\311/\215j\301n\330O\n\253\301N\210\341\220/\205/#3:T+I\355\305\r\376\325\315h#\252F}\r\2644\252\216>\204\217\303FR\270s\256a\237\307\225\270>\316\335\004[\230\024\036G/\225\251\016\343\225\344\307\3325\234\323p%)\334\r*\311\235\225\240\024\276V\351\255\032\034\207\215\220D\225\363\013\2403\363<_\030""\275\206`x\325\203\245\360\027\225\313\362\362_\215R\260/Gv\360\235\366\337\017\357\247%>\304\033\311nY\273\326\203\214\3107\300X\323}1\316\215\327\306\357>\346>B8`\004\246F5G\r\rv\022\014\262\202\372\"\203\312Y.YX\034=\r\032\223\205b\010-~\035\340\363\374\203\311\203\247\252\242\352q.\331\331Mv~\210\0331X\213\223\342\266\332PU\005\345\326'\353[*\247\326\324?q_+\2638z2\302\232%\326\265~\017\356\005X7\231\024\200~\262|/h$\313w\203Z\270\031\232\311Z1\274\035\366\243\205hO=WXq\020\316\3706j\253\277\343\\\274\032W\022\343\311\234\007R\217\302W\232qt\013\364\232\273\346Ri>\307zJiJ\357\277:\270\302\032\002g\316\244\360(|\237^\336A\034Ll+mc\371Q\350\252\206\262\343\355\261\251\233\253\006\034\306\263\246\207Q\324\223(\226\302Z\264\031\231\311C#\272\035\365\325\202\332\213\277\007JM\000\331*\253v|\000u\277\030o$[;s\036H=\212^E\030\022nA/\246z\033o\234_3\202\232\017\303\277\322^\027\001ay3\332NW\2604N\307\332\377\027\233\017\355\314"; - PyObject *data = __Pyx_DecompressString(cstring, 1030, 1); + #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1043 bytes) */ +const char* const cstring = "x\332\215S\317o\3336\024\236\327`\365\022wK\262tq\352\256P\322b\013\332\304E\326\240i\207\375\200\n\017\301\200\265\213\263\024\001\326\003AK\264\303Z\241d\222\212\343\364\222\243\217:\362\250\243\216:\372O\350\321G\035\375'\354O\330#\345\270N\223a3 \213\217\357\275\217\337\367\361i\3635k3\277\313,\312\202PZ\262\027\220_\\*p\303#\204\351\377\226C[\314\347\224\265\254\000s\354y\304\263\210\333\"\026\025y\201\033x\230aNe\357\007\353\002\214p\356\363\352$\361\330\361\260\020\324y<\331\251\006\275\323\251\276&\246\000da\327\325\347h\370\352\325\254\364-r*\ts\255\026\307\301\221\325\245\362\310\232\224YB\362\320\221!'\342\377\366\272\034w\363\322\377l\246\214J\212=zFr\200\251\242\034\220\371r\314\245*\210\327\254\312#\262k\022\016f:\327 \226\343\263\023\302e\016\210\255\275\236<\362\231\3457\336\022GZM\237[\001u\332\036\030\360#\260\201\227\360C\356\220\237k\373\366\341\336\357\366+{\037\375V\3333\240\371\177\025!N\334\320!\3101P\010M\366\005\221Bby%\203\205C\351x\255]\026\027\353\343\006q\321\007?.m_\332\242\342r\334\0169\226~W\264)\232\006<\306A\000\022\306\021\363\335I\246\013\256\021 \324;\205\247F\035\211^\301\315\354\223\246\341\206E\2179\324\257:>\367CI\031\021\215\000\313#\007l!\2102$9vH\003;m0SB\237\213%\326\264\341,b\316\377X\311\264\004\302\034 \002C\220\217B\223r!\021j\206\314A\360k]x\206\314\215\"P:a\001k\215>\021\017\022\216E\233\364\304\307\362a\316\001\362\030\003U4\366\000\026\276\033z\200\013{\014\037\353E\203\033K\264\264\017\237\304\370#\3710\200\201\037\004\276\010z\250\321\223D \004\337\014\032S\354\204\330\313\261\370d\n\320\225y\230l\220S\230\t=\227f4\306,`\345\202\355\241'\247\006\006]3<\020q\263\025\002\t`\002\365a\000\316\223\023\354\205Dt1g\372\321#kn\367\214\006\347vV\254\014+\333\251\235\036\014\026\262\342\\\177'\332T\235\254\264\030m(\014\213bE=\217\355\370 Y\310v\236]\223_\\\213W\343\355\270\243\201\346\372\333\375w\352\276\252g\245[#\r\373$\335Jk\203\302u\260\245a\351~\374<\261\223\203t!{\272s\005\347L-d\245\257\242\255\354\326BTQ/\023""\023mG'\252\256H\2745\272\000:\267G\305R\377%\024\303\253\026\315\251\237\222B\336W\374\262o\300\276\350\273\321w:\277\242V\314\021\357\322\325l\263\252S\313QN\344\033`\254\351>\033\024\006K\2037\357\013\357\241\0340\"[\243\332\375\272\006;\215\272\371\201:\220\321\326y!\233\231\355?\212\352\303\231\262\002\211_GxT\2743\274\363(\331Jji!\333\330\3146\236\2468\355h\n8+\316\366\037\350WyX\256&8\221)0\\\036.o&\365\304\005Bp\316\257\321\355\010k\201Y\t\212\326\223B\262\224\374\005\355\245{\352\255\t\336\200\223\240{]\255);\233\277\247|\323\373p\000\201\266\206\203\310%-\251\254\365\224+j'^\213\355\354\256\025\337\214;\311L\262\233~\237\326\323\006\200\254W\223V\272\237v\006\237\016V\263\365\215\251\014\264\036\306/b\014\r7@\207\235\274NWGW6\353\331\374]\365\207\3219\013\010\363k\361Cs\221\225\2011\2473\234Y\321\206\203#\177\177\366\311\347\225k<\031\375\253\017c\233\214e\227<\001\334l\376vT\327bw\214\005KeuSu\342\231x7y\002P\034\006\311\3726n%\177\246\205t\021p\255\007S\031h=T/\364\r\3067`~\246\302\202\341\374\017\305\361\354\003"; + PyObject *data = __Pyx_DecompressString(cstring, 1043, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #else /* compression: none (1894 bytes) */ -const char* const bytes = "-Unknown input type?disableenablegcignoring parallel edge isenabledplanarity: Unknown error.planarity/classic/planarity.pyxplanarity: failed adding edge.planarity: failed to extend graph with planarity structures.planarity: failed to extend graph with drawplanar structures.planarity: failed to initialize graphplanarity: graph not planar.self.theGraph cannot be converted to a Python object for picklingDRAWPLANAR_IDPGraphPGraph.__reduce_cython__PGraph.__setstate_cython__PGraph.asciiPGraph.edgesPGraph.embed_drawplanarPGraph.embed_planarPGraph.is_planarPGraph.kuratowski_edgesPGraph.mappingPGraph.nodesPGraph.write__Pyx_PyDict_NextRefasciiasyncio.coroutinesbpathcline_in_tracebackcontextdatadrawingeedgesembed_drawplanarembed_planarencodeendextendfirst__func____getstate__graph_is_coroutineis_edgeis_planaritemskeyskuratowski_edgeslast__main__mapping__module__n__name__nbrnodespathplanarity.classic.planaritypoppospy_bytes__pyx_state__qualname__r__reduce____reduce_cython____reduce_ex__sself__set_name__setdefault__setstate____setstate_cython__startstatus__test__updatevalueswarnwarningswritezip\200A\330\010\033\320\0334\260A\260T\270\021\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\010\033\2309\240A\240T\250\021\33078\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\022\"\240!\2404\240q\200A\330\010\013\2104\210{\230#\230Q\330\014\r\340\010\033\320\0333\2601\260D\270\001\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\010\014\320\014#\2409\250A\250T\260\021\33067\330\022\"\240!\2404\240q\200A\330\010\013\2104\210z\230\021\330\014\023\2201\330\r\021\220\033\230M\250\021\330\014\023\2204\220v\230Q\230e\2401\340\014\022\220,\230a\230q\200A\340\010\014\210M\230\021\330\010\014\210D\220\013\230=\250\001\330\014\023\2201\330\010\017\210q\200A\330\010\016\210d\220'\230\021\330\010\031\230\031\240!\2404\240{\260!\330-.\200A\330\010\027\220q\330\010\014\320\014\035\230Q\330\010\033\320\0338\270\001\270\024\270[\310\001\310\021\330\010\023\2201""\220A\330\010\014\210A\210Q\330\010\017\210x\220w\230a\230q\200A\330\010\017\210t\2201\200\001\330\004\n\210+\220Q\320\004\030\230\001\330\010\026\220a\340\010\032\320\032+\2501\250D\260\001\330,-\330,5\260Q\260a\340\010\030\320\030*\250!\2504\250q\330\010\027\320\027(\250\001\250\024\250Z\260q\270\001\330\010\n\210$\210a\330\010\016\210a\330\010\014\210E\220\025\220a\220v\230Q\330\014\017\210q\330\020\025\220Q\330\020\023\2207\230\"\230A\330\024\030\230\007\230q\240\004\240G\2503\250a\250r\260\021\330 &\240g\250S\260\001\260\022\2601\330 $\240G\2503\250a\250r\260\021\330\020\025\220W\230B\230a\230q\240\003\2401\340\020\025\220W\230B\230a\230q\240\001\330\010\017\210q\320\004\030\230\001\330\010\026\220a\340\010\032\320\032+\2501\250D\260\001\330,-\330,5\260Q\260a\330\010\016\210a\330\010\n\210$\210a\330\010\030\320\030*\250!\2504\250q\330\010\027\320\027(\250\001\250\024\250Z\260q\270\001\330\010\014\210E\220\025\220a\220v\230Q\330\014\030\320\030(\250\001\250\024\250Z\260q\330\014\036\230j\250\001\250\024\250[\270\001\330\014\022\220(\230\"\230A\330\020\036\230o\250Q\250d\260*\270A\330\020\023\2204\220r\230\021\330\024\027\220q\330\030\035\230Q\330\030\033\2307\240\"\240A\330\034 \240\007\240q\250\004\250G\2602\260Q\260b\270\001\330(.\250g\260R\260q\270\002\270!\330(,\250G\2602\260Q\260b\270\001\330\030\035\230W\240B\240a\240q\250\003\2501\250A\250U\260!\340\030\035\230W\240B\240a\240q\250\003\2501\250A\250Q\330\020\034\230O\2501\250D\260\n\270!\330\020\"\240*\250A\250T\260\033\270A\330\010\017\210q"; + #else /* compression: none (1888 bytes) */ +const char* const bytes = "-Unknown input type?disableenablegcignoring parallel edge isenabledplanarity: Unknown error.planarity/classic/planarity.pyxplanarity: failed adding edge.planarity: failed to extend graph with planarity structures.planarity: failed to extend graph with drawplanar structures.planarity: failed to initialize graphplanarity: graph not planar.self.theGraph cannot be converted to a Python object for picklingDRAWPLANAR_IDPGraphPGraph.__reduce_cython__PGraph.__setstate_cython__PGraph.asciiPGraph.edgesPGraph.embed_drawplanarPGraph.embed_planarPGraph.is_planarPGraph.kuratowski_edgesPGraph.mappingPGraph.nodesPGraph.write__Pyx_PyDict_NextRefasciiasyncio.coroutinesbpathcline_in_tracebackcontextdatadrawingeedgesembed_drawplanarembed_planarencodeendextendfirst__func____getstate__graph_is_coroutineis_edgeis_planaritemskeyskuratowski_edgeslast__main__mapping__module__n__name__nbrnodespathplanarity.classic.planaritypoppospy_bytes__pyx_state__qualname__r__reduce____reduce_cython____reduce_ex__sself__set_name__setdefault__setstate____setstate_cython__startstatus__test__updatevalueswarnwarningswritezip\200A\330\010\033\320\0334\260A\260T\270\021\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\010\033\2309\240A\240T\250\021\33078\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\022\"\240!\2404\240q\200A\330\010\013\2104\210{\230#\230Q\330\014\r\340\010\033\320\0333\2601\260D\270\001\330\010\013\2107\220-\230q\330\014\022\220,\230a\230q\330\010\014\320\014#\2409\250A\250T\260\021\33067\330\022\"\240!\2404\240q\200A\330\010\013\2104\210z\230\021\330\014\023\2201\330\r\021\220\033\230M\250\021\330\014\023\2204\220v\230Q\230e\2401\340\014\022\220,\230a\230q\200A\340\010\014\210M\230\021\330\010\014\210D\220\013\230=\250\001\330\014\023\2201\330\010\017\210q\200A\330\010\016\210d\220'\230\021\330\010\031\230\031\240!\2404\240{\260!\330-.\200A\330\010\027\220q\330\010\014\320\014\035\230Q\330\010\033\320\0338\270\001\270\024\270[\310\001\310\021\330\010\023\2201""\220A\330\010\014\210A\210Q\330\010\017\210x\220w\230a\230q\200A\330\010\017\210t\2201\200\001\330\004\n\210+\220Q\320\004\030\230\001\330\010\026\220a\340\010\032\320\032+\2501\250D\260\001\330,-\330,6\260a\260q\330\010\016\210a\330\010\n\210$\210a\330\010\030\320\030.\250a\250t\2601\330\010\027\320\027-\250Q\250d\260!\330\010\014\210E\220\025\220a\220v\230Q\330\014\030\320\030(\250\001\250\024\250Z\260q\330\014\036\230j\250\001\250\024\250[\270\001\330\014\022\220(\230\"\230A\330\020\036\230o\250Q\250d\260*\270A\330\020\023\2204\220r\230\021\330\024\027\220q\330\030\035\230Q\330\030\033\2307\240\"\240A\330\034 \240\007\240q\250\004\250G\2602\260Q\260b\270\001\330(.\250g\260R\260q\270\002\270!\330(,\250G\2602\260Q\260b\270\001\330\030\035\230W\240B\240a\240q\250\003\2501\250A\250U\260!\340\030\035\230W\240B\240a\240q\250\003\2501\250A\250Q\330\020\034\230O\2501\250D\260\n\270!\330\020\"\240*\250A\250T\260\033\270A\330\010\017\210q\320\004\031\230\021\330\010\026\220a\360\006\000\t\033\320\032+\2501\250D\260\001\330,-\330,6\260a\260q\340\010\030\320\030.\250a\250t\2601\330\010\027\320\027-\250Q\250d\260!\330\010\n\210$\210a\330\010\016\210a\330\010\014\210E\220\025\220a\220v\230Q\330\014\017\210q\330\020\025\220Q\330\020\023\2207\230\"\230A\330\024\030\230\007\230q\240\004\240G\2503\250a\250r\260\021\330 &\240g\250S\260\001\260\022\2601\330 $\240G\2503\250a\250r\260\021\330\020\025\220W\230B\230a\230q\240\003\2401\340\020\025\220W\230B\230a\230q\240\001\330\010\017\210q"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif @@ -7223,25 +7229,25 @@ static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 10, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 108}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_DRAWPLANAR_ID, __pyx_mstate->__pyx_n_u_context, __pyx_mstate->__pyx_n_u_drawing, __pyx_mstate->__pyx_n_u_first, __pyx_mstate->__pyx_n_u_last, __pyx_mstate->__pyx_n_u_r, __pyx_mstate->__pyx_n_u_nodes, __pyx_mstate->__pyx_n_u_n}; - __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_nodes, __pyx_mstate->__pyx_kp_b_iso88591_a_1D_5Qa_4q_Zq_a_a_E_avQ_q_Q_7, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_nodes, __pyx_mstate->__pyx_kp_b_iso88591_a_1D_6aq_at1_Qd_a_a_E_avQ_q_Q_7, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 132}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 133}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_DRAWPLANAR_ID, __pyx_mstate->__pyx_n_u_context, __pyx_mstate->__pyx_n_u_drawing, __pyx_mstate->__pyx_n_u_edges, __pyx_mstate->__pyx_n_u_r, __pyx_mstate->__pyx_n_u_first, __pyx_mstate->__pyx_n_u_last, __pyx_mstate->__pyx_n_u_n, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_is_edge, __pyx_mstate->__pyx_n_u_nbr}; - __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_edges, __pyx_mstate->__pyx_kp_b_iso88591_a_1D_5Qa_a_a_4q_Zq_E_avQ_Zq_j_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_edges, __pyx_mstate->__pyx_kp_b_iso88591_a_1D_6aq_a_a_at1_Qd_E_avQ_Zq_j, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 162}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 163}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_s, __pyx_mstate->__pyx_n_u_status, __pyx_mstate->__pyx_n_u_py_bytes}; __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_ascii, __pyx_mstate->__pyx_kp_b_iso88591_A_q_Q_8_1A_AQ_xwaq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 171}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 172}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_path, __pyx_mstate->__pyx_n_u_bpath, __pyx_mstate->__pyx_n_u_status}; __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_write, __pyx_mstate->__pyx_kp_b_iso88591_A_d_4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 176}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 177}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_classic_planarity_pyx, __pyx_mstate->__pyx_n_u_mapping, __pyx_mstate->__pyx_kp_b_iso88591_A_t1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; } @@ -12274,6 +12280,45 @@ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) { } } +/* FormatTypeName */ +#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 +static __Pyx_TypeName +__Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) +{ + PyObject *module = NULL, *name = NULL, *result = NULL; + #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 + name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, + __pyx_mstate_global->__pyx_n_u_qualname); + #else + name = PyType_GetQualName(tp); + #endif + if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; + module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, + __pyx_mstate_global->__pyx_n_u_module); + if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; + if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { + result = name; + name = NULL; + goto done; + } + result = PyUnicode_FromFormat("%U.%U", module, name); + if (unlikely(result == NULL)) goto bad; + done: + Py_XDECREF(name); + Py_XDECREF(module); + return result; + bad: + PyErr_Clear(); + if (name) { + result = name; + name = NULL; + } else { + result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2); + } + goto done; +} +#endif + /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC @@ -12593,45 +12638,6 @@ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { return (long) -1; } -/* FormatTypeName */ -#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 -static __Pyx_TypeName -__Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) -{ - PyObject *module = NULL, *name = NULL, *result = NULL; - #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 - name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, - __pyx_mstate_global->__pyx_n_u_qualname); - #else - name = PyType_GetQualName(tp); - #endif - if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; - module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, - __pyx_mstate_global->__pyx_n_u_module); - if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; - if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { - result = name; - name = NULL; - goto done; - } - result = PyUnicode_FromFormat("%U.%U", module, name); - if (unlikely(result == NULL)) goto bad; - done: - Py_XDECREF(name); - Py_XDECREF(module); - return result; - bad: - PyErr_Clear(); - if (name) { - result = name; - name = NULL; - } else { - result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2); - } - goto done; -} -#endif - /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { diff --git a/planarity/classic/planarity.pyx b/planarity/classic/planarity.pyx index fee2490..a9450a0 100644 --- a/planarity/classic/planarity.pyx +++ b/planarity/classic/planarity.pyx @@ -49,10 +49,10 @@ cdef class PGraph: seen = set() for u,v in edges: if (u,v) not in seen and (v,u) not in seen: - status = cplanarity.gp_AddEdge(self.theGraph, + status = cplanarity.gp_DynamicAddEdge(self.theGraph, self.nodemap[u], 0, self.nodemap[v], 0) - if status == cplanarity.NOTOK: + if status != cplanarity.OK: cplanarity.gp_Free(&self.theGraph) raise RuntimeError("planarity: failed adding edge.") seen.add((u,v)) @@ -70,7 +70,7 @@ cdef class PGraph: return status = cplanarity.gp_ExtendWith_Planarity(self.theGraph) - if status == cplanarity.NOTOK: + if status != cplanarity.OK: raise RuntimeError("planarity: failed to extend graph with planarity structures.") self.embedding = cplanarity.gp_Embed(self.theGraph, cplanarity.EMBEDFLAGS_PLANAR) @@ -79,7 +79,7 @@ cdef class PGraph: def embed_drawplanar(self): status = cplanarity.gp_ExtendWith_DrawPlanar(self.theGraph) - if status == cplanarity.NOTOK: + if status != cplanarity.OK: raise RuntimeError("planarity: failed to extend graph with drawplanar structures.") status = cplanarity.gp_Embed(self.theGraph, cplanarity.EMBEDFLAGS_DRAWPLANAR) @@ -105,15 +105,16 @@ cdef class PGraph: raise RuntimeError("planarity: Unknown error.") - def nodes(self,data=False): + def nodes(self, data=False): DRAWPLANAR_ID=1 - cdef cplanarity.DrawPlanarContext *context + cdef cplanarity.DrawPlanarContext *context + drawing=cplanarity.gp_FindExtension(self.theGraph, DRAWPLANAR_ID, - &context) + &context) - first=cplanarity.gp_GetFirstVertex(self.theGraph) - last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + first=cplanarity.gp_LowerBoundVertices(self.theGraph) + last=cplanarity.gp_UpperBoundVertices(self.theGraph) r=self.reverse_nodemap nodes=[] for n in range(first,last): @@ -134,11 +135,11 @@ cdef class PGraph: cdef cplanarity.DrawPlanarContext *context drawing=cplanarity.gp_FindExtension(self.theGraph, DRAWPLANAR_ID, - &context) + &context) edges=[] r=self.reverse_nodemap - first=cplanarity.gp_GetFirstVertex(self.theGraph) - last=cplanarity.gp_GetLastVertex(self.theGraph)+1 + first=cplanarity.gp_LowerBoundVertices(self.theGraph) + last=cplanarity.gp_UpperBoundVertices(self.theGraph) for n in range(first,last): e=cplanarity.gp_GetFirstEdge(self.theGraph,n) is_edge=cplanarity.gp_IsEdge(self.theGraph, e) diff --git a/planarity/full/cgraphLib.pxd b/planarity/full/cgraphLib.pxd index 53af576..d14a2ed 100644 --- a/planarity/full/cgraphLib.pxd +++ b/planarity/full/cgraphLib.pxd @@ -4,70 +4,82 @@ Specifically provides definitions for functions and macros that are required to interact with graphP structs. """ -cdef extern from "../c/graphLib/graphLib.h": - char *gp_GetProjectVersionFull() - char *gp_GetLibPlanarityVersionFull() +cdef extern from "../c/graphLib/graph.h": + ctypedef struct graphStruct: + pass + ctypedef graphStruct * graphP + + graphP gp_New() + int gp_InitGraph(graphP theGraph, int N) + void gp_ReinitGraph(graphP theGraph) + void gp_Free(graphP *pGraph) -cdef extern from "../c/graphLib/graphStructures.h": - int NONEMBEDDABLE + int gp_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) + + int gp_GetEdgeCapacity(graphP theGraph) + + int gp_GetN(graphP theGraph) + + int gp_CopyGraph(graphP dstGraph, graphP srcGraph) + graphP gp_DupGraph(graphP theGraph) + + int gp_FindEdge(graphP theGraph, int u, int v) + int gp_GetVertexDegree(graphP theGraph, int v) + + int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) + int gp_DeleteEdge(graphP theGraph, int e) - ctypedef struct baseGraphStructure: + int AT_EDGE_CAPACITY_LIMIT + + ctypedef struct edgeRec: pass - ctypedef baseGraphStructure * graphP + ctypedef edgeRec * edgeRecP + + int gp_LowerBoundEdgeStorage(graphP theGraph) + int gp_UpperBoundEdgeStorage(graphP theGraph) + + int gp_IsEdge(graphP theGraph, int v) - int gp_IsEdge(graphP theGraph, int e) - int gp_EdgeArrayStart(graphP theGraph) int gp_EdgeInUse(graphP theGraph, int e) - int gp_EdgeArraySize(graphP theGraph) - int gp_EdgeInUseArraySize(graphP theGraph) + + int gp_UpperBoundEdges(graphP theGraph) + + int gp_GetNextEdge(graphP theGraph, int v) + + int gp_GetNeighbor(graphP theGraph, int v) + int gp_GetFirstEdge(graphP theGraph, int v) - int gp_GetNextEdge(graphP theGraph, int e) - int gp_GetNeighbor(graphP theGraph, int e) + int gp_LowerBoundVertices(graphP theGraph) + int gp_UpperBoundVertices(graphP theGraph) int gp_IsVertex(graphP theGraph, int v) - int gp_GetFirstVertex(graphP theGraph) - int gp_GetLastVertex(graphP theGraph) - int gp_VertexInRangeAscending(graphP theGraph, int v) - int gp_ExtendWith_Planarity(graphP theGraph) - int gp_ExtendWith_Outerplanarity(graphP theGraph) +cdef extern from "../c/graphLib/graphLib.h": + char *gp_GetProjectVersionFull() + char *gp_GetLibPlanarityVersionFull() -cdef extern from "../c/graphLib/graph.h": - int EMBEDFLAGS_PLANAR, EMBEDFLAGS_DRAWPLANAR, EMBEDFLAGS_OUTERPLANAR - int EMBEDFLAGS_SEARCHFORK23, EMBEDFLAGS_SEARCHFORK33, EMBEDFLAGS_SEARCHFORK4 - int WRITE_ADJLIST, WRITE_ADJMATRIX, WRITE_G6 +cdef extern from "../c/graphLib/homeomorphSearch/graphK23Search.h": + int gp_ExtendWith_K23Search(graphP theGraph) - graphP gp_New() - int gp_InitGraph(graphP theGraph, int N) - void gp_ReinitializeGraph(graphP theGraph) - void gp_Free(graphP *pGraph) - int gp_GetN(graphP theGraph) +cdef extern from "../c/graphLib/homeomorphSearch/graphK33Search.h": + int gp_ExtendWith_K33Search(graphP theGraph) - int gp_CopyGraph(graphP dstGraph, graphP srcGraph) - graphP gp_DupGraph(graphP theGraph) - int gp_Read(graphP theGraph, char *FileName) - int gp_ReadFromString(graphP theGraph, char *inputStr) +cdef extern from "../c/graphLib/homeomorphSearch/graphK4Search.h": + int gp_ExtendWith_K4Search(graphP theGraph) - int gp_Write(graphP theGraph, char *FileName, int Mode) - int gp_WriteToString(graphP theGraph, char **pOutputStr, int Mode) - int gp_FindEdge(graphP theGraph, int u, int v) - int gp_GetVertexDegree(graphP theGraph, int v) +cdef extern from "../c/graphLib/io/graphIO.h": + int gp_Read(graphP theGraph, char *FileName) - int gp_GetEdgeCapacity(graphP theGraph) - int gp_EnsureEdgeCapacity(graphP theGraph, int requiredEdgeCapacity) + int gp_Write(graphP theGraph, char *FileName, int Mode) - int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink) - int gp_DeleteEdge(graphP theGraph, int e) - - int gp_Embed(graphP theGraph, int embedFlags) - int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResult) + int WRITE_ADJLIST, WRITE_ADJMATRIX, WRITE_G6 cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.h": @@ -77,13 +89,16 @@ cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.h": int gp_DrawPlanar_RenderToString(graphP theEmbedding, char **pRenditionString) -cdef extern from "../c/graphLib/homeomorphSearch/graphK23Search.h": - int gp_ExtendWith_K23Search(graphP theGraph) +cdef extern from "../c/graphLib/planarityRelated/graphOuterplanarity.h": + int gp_ExtendWith_Outerplanarity(graphP theGraph) -cdef extern from "../c/graphLib/homeomorphSearch/graphK33Search.h": - int gp_ExtendWith_K33Search(graphP theGraph) +cdef extern from "../c/graphLib/planarityRelated/graphPlanarity.h": + int gp_ExtendWith_Planarity(graphP theGraph) + int gp_Embed(graphP theGraph, unsigned int embedFlags) + int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResult) -cdef extern from "../c/graphLib/homeomorphSearch/graphK4Search.h": - int gp_ExtendWith_K4Search(graphP theGraph) + int NONEMBEDDABLE + int EMBEDFLAGS_PLANAR, EMBEDFLAGS_DRAWPLANAR, EMBEDFLAGS_OUTERPLANAR + int EMBEDFLAGS_SEARCHFORK23, EMBEDFLAGS_SEARCHFORK33, EMBEDFLAGS_SEARCHFORK4 diff --git a/planarity/full/g6IterationUtils.c b/planarity/full/g6IterationUtils.c index e316bd7..e2cc618 100644 --- a/planarity/full/g6IterationUtils.c +++ b/planarity/full/g6IterationUtils.c @@ -10,7 +10,8 @@ "sources": [ "planarity/full/g6IterationUtils.pyx", "planarity/c/graphLib/graphDFSUtils.c", - "planarity/c/graphLib/graphUtils.c", + "planarity/c/graphLib/graphLib.c", + "planarity/c/graphLib/graph.c", "planarity/c/graphLib/io/g6-api-utilities.c", "planarity/c/graphLib/io/g6-read-iterator.c", "planarity/c/graphLib/io/strOrFile.c", @@ -25,10 +26,12 @@ "planarity/c/graphLib/homeomorphSearch/graphK33Search.c", "planarity/c/graphLib/homeomorphSearch/graphK23Search.c", "planarity/c/graphLib/planarityRelated/graphTests.c", + "planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphEmbed.c", "planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c", "planarity/c/graphLib/planarityRelated/graphNonplanar.c", "planarity/c/graphLib/planarityRelated/graphIsolator.c", + "planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c", "planarity/c/graphLib/lowLevelUtils/stack.c", @@ -1158,13 +1161,15 @@ static int __Pyx_init_co_variables(void) { #define __PYX_HAVE_API__planarity__full__g6IterationUtils /* Early includes */ #include "../c/graphLib/lowLevelUtils/appconst.h" -#include "../c/graphLib/graphLib.h" -#include "../c/graphLib/graphStructures.h" #include "../c/graphLib/graph.h" -#include "../c/graphLib/planarityRelated/graphDrawPlanar.h" +#include "../c/graphLib/graphLib.h" #include "../c/graphLib/homeomorphSearch/graphK23Search.h" #include "../c/graphLib/homeomorphSearch/graphK33Search.h" #include "../c/graphLib/homeomorphSearch/graphK4Search.h" +#include "../c/graphLib/io/graphIO.h" +#include "../c/graphLib/planarityRelated/graphDrawPlanar.h" +#include "../c/graphLib/planarityRelated/graphOuterplanarity.h" +#include "../c/graphLib/planarityRelated/graphPlanarity.h" #include "../c/graphLib/io/g6-read-iterator.h" #include "../c/graphLib/io/g6-write-iterator.h" #ifdef _OPENMP diff --git a/planarity/full/g6IterationUtils.pyx b/planarity/full/g6IterationUtils.pyx index 62468a1..b6fbb9e 100644 --- a/planarity/full/g6IterationUtils.pyx +++ b/planarity/full/g6IterationUtils.pyx @@ -61,7 +61,7 @@ cdef class G6ReadIterator: f"Unable to read graph, as g6_ReadGraph() in EAPS graphLib " "failed." ) - + cdef class G6WriteIterator: cdef cg6IterationDefs.G6WriteIteratorP _g6WriteIterator diff --git a/planarity/full/graph.c b/planarity/full/graph.c index d06a1d6..b350e0a 100644 --- a/planarity/full/graph.c +++ b/planarity/full/graph.c @@ -11,7 +11,8 @@ "sources": [ "planarity/full/graph.pyx", "planarity/c/graphLib/graphDFSUtils.c", - "planarity/c/graphLib/graphUtils.c", + "planarity/c/graphLib/graphLib.c", + "planarity/c/graphLib/graph.c", "planarity/c/graphLib/io/g6-api-utilities.c", "planarity/c/graphLib/io/g6-read-iterator.c", "planarity/c/graphLib/io/strOrFile.c", @@ -26,10 +27,12 @@ "planarity/c/graphLib/homeomorphSearch/graphK33Search.c", "planarity/c/graphLib/homeomorphSearch/graphK23Search.c", "planarity/c/graphLib/planarityRelated/graphTests.c", + "planarity/c/graphLib/planarityRelated/graphPlanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphEmbed.c", "planarity/c/graphLib/planarityRelated/graphOuterplanarObstruction.c", "planarity/c/graphLib/planarityRelated/graphNonplanar.c", "planarity/c/graphLib/planarityRelated/graphIsolator.c", + "planarity/c/graphLib/planarityRelated/graphOuterplanarity_Extensions.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar.c", "planarity/c/graphLib/planarityRelated/graphDrawPlanar_Extensions.c", "planarity/c/graphLib/lowLevelUtils/stack.c", @@ -1158,13 +1161,15 @@ static int __Pyx_init_co_variables(void) { #define __PYX_HAVE__planarity__full__graph #define __PYX_HAVE_API__planarity__full__graph /* Early includes */ -#include "../c/graphLib/graphLib.h" -#include "../c/graphLib/graphStructures.h" #include "../c/graphLib/graph.h" -#include "../c/graphLib/planarityRelated/graphDrawPlanar.h" +#include "../c/graphLib/graphLib.h" #include "../c/graphLib/homeomorphSearch/graphK23Search.h" #include "../c/graphLib/homeomorphSearch/graphK33Search.h" #include "../c/graphLib/homeomorphSearch/graphK4Search.h" +#include "../c/graphLib/io/graphIO.h" +#include "../c/graphLib/planarityRelated/graphDrawPlanar.h" +#include "../c/graphLib/planarityRelated/graphOuterplanarity.h" +#include "../c/graphLib/planarityRelated/graphPlanarity.h" #include #include #include "../c/graphLib/lowLevelUtils/appconst.h" @@ -1704,46 +1709,6 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif -/* decode_c_string_utf16.proto (used by decode_c_bytes) */ -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = 0; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = -1; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = 1; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} - -/* decode_c_bytes.proto (used by decode_bytes) */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( - const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); - -/* decode_bytes.proto */ -static CYTHON_INLINE PyObject* __Pyx_decode_bytes( - PyObject* string, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - char* as_c_string; - Py_ssize_t size; -#if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE - as_c_string = PyBytes_AS_STRING(string); - size = PyBytes_GET_SIZE(string); -#else - if (PyBytes_AsStringAndSize(string, &as_c_string, &size) < 0) { - return NULL; - } -#endif - return __Pyx_decode_c_bytes( - as_c_string, size, - start, stop, encoding, errors, decode_func); -} - /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); @@ -1943,48 +1908,6 @@ static CYTHON_INLINE int __Pyx_ParseKeywords( int ignore_unknown_kwargs ); -/* PyObjectFastCallMethod.proto */ -#if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000 -#define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL) -#else -static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); -#endif - -/* PyRuntimeError_Check.proto */ -#define __Pyx_PyExc_RuntimeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_RuntimeError) - -/* BuildPyUnicode.proto (used by COrdinalToPyUnicode) */ -static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength, - int prepend_sign, char padding_char); - -/* COrdinalToPyUnicode.proto (used by CIntToPyUnicode) */ -static CYTHON_INLINE int __Pyx_CheckUnicodeValue(int value); -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromOrdinal_Padded(int value, Py_ssize_t width, char padding_char); - -/* GCCDiagnostics.proto (used by CIntToPyUnicode) */ -#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* IncludeStdlibH.proto (used by CIntToPyUnicode) */ -#include - -/* CIntToPyUnicode.proto */ -#define __Pyx_PyUnicode_From_int(value, width, padding_char, format_char) (\ - ((format_char) == ('c')) ?\ - __Pyx_uchar___Pyx_PyUnicode_From_int(value, width, padding_char) :\ - __Pyx____Pyx_PyUnicode_From_int(value, width, padding_char, format_char)\ - ) -static CYTHON_INLINE PyObject* __Pyx_uchar___Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char); -static CYTHON_INLINE PyObject* __Pyx____Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char); - -/* JoinPyUnicode.export */ -static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, - Py_UCS4 max_char); - -/* pyint_simplify.proto */ -static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none); - /* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) @@ -2046,6 +1969,41 @@ static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_ve static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif +/* PyRuntimeError_Check.proto */ +#define __Pyx_PyExc_RuntimeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_RuntimeError) + +/* BuildPyUnicode.proto (used by COrdinalToPyUnicode) */ +static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength, + int prepend_sign, char padding_char); + +/* COrdinalToPyUnicode.proto (used by CIntToPyUnicode) */ +static CYTHON_INLINE int __Pyx_CheckUnicodeValue(int value); +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromOrdinal_Padded(int value, Py_ssize_t width, char padding_char); + +/* GCCDiagnostics.proto (used by CIntToPyUnicode) */ +#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif + +/* IncludeStdlibH.proto (used by CIntToPyUnicode) */ +#include + +/* CIntToPyUnicode.proto */ +#define __Pyx_PyUnicode_From_int(value, width, padding_char, format_char) (\ + ((format_char) == ('c')) ?\ + __Pyx_uchar___Pyx_PyUnicode_From_int(value, width, padding_char) :\ + __Pyx____Pyx_PyUnicode_From_int(value, width, padding_char, format_char)\ + ) +static CYTHON_INLINE PyObject* __Pyx_uchar___Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char); +static CYTHON_INLINE PyObject* __Pyx____Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char); + +/* JoinPyUnicode.export */ +static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, + Py_UCS4 max_char); + +/* pyint_simplify.proto */ +static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none); + /* ArgTypeTestFunc.export */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); @@ -2054,6 +2012,13 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) +/* PyObjectFastCallMethod.proto */ +#if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000 +#define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL) +#else +static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); +#endif + /* PyLongCompare.proto */ static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); @@ -2095,6 +2060,20 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, /* PyUnicode_Unicode.proto */ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj); +/* decode_c_string_utf16.proto (used by decode_c_string) */ +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + /* decode_c_string.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, @@ -2104,6 +2083,32 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( /* PyTypeError_Check.proto */ #define __Pyx_PyExc_TypeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_TypeError) +/* decode_c_bytes.proto (used by decode_bytes) */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/* decode_bytes.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_bytes( + PyObject* string, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + char* as_c_string; + Py_ssize_t size; +#if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE + as_c_string = PyBytes_AS_STRING(string); + size = PyBytes_GET_SIZE(string); +#else + if (PyBytes_AsStringAndSize(string, &as_c_string, &size) < 0) { + return NULL; + } +#endif + return __Pyx_decode_c_bytes( + as_c_string, size, + start, stop, encoding, errors, decode_func); +} + /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); @@ -2467,47 +2472,46 @@ int __pyx_module_is_main_planarity__full__graph = 0; /* #### Code section: string_decls ### */ static const char __pyx_k_Cython_wrapper_for_the_Edge_Add[] = "\nCython wrapper for the Edge Addition Planarity Suite Graph Library\n\nWraps a graphP struct using a Cython class and wraps functions and macros that\noperate over graphP structs.\n"; /* #### Code section: decls ### */ -static PyObject *__pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ static void __pyx_pf_9planarity_4full_5graph_5Graph_2__dealloc__(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_4gp_IsEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_8gp_EdgeInUse(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_16gp_GetNextEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_18gp_GetNeighbor(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_IsVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_24gp_GetLastVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_28gp_GetN(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_30gp_InitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_34gp_CopyGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph); /* proto */ -static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pf_9planarity_4full_5graph_5Graph_36gp_DupGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_38gp_Read(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_infile_name); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_40gp_Write(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name, PyObject *__pyx_v_mode); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_FindEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_v); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_new_edge_capacity); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_50gp_AddEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_ulink, int __pyx_v_v, int __pyx_v_vlink); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_52gp_DeleteEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_embedFlags); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_copy_of_orig_graph, int __pyx_v_embed_result); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_4gp_InitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_n); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_6gp_ReinitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_new_edge_capacity); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_12gp_GetN(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_14gp_CopyGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph); /* proto */ +static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pf_9planarity_4full_5graph_5Graph_16gp_DupGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_18gp_FindEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_v); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_22gp_AddEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_ulink, int __pyx_v_v, int __pyx_v_vlink); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_24gp_DeleteEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_30gp_IsEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_32gp_EdgeInUse(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_36gp_GetNextEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_38gp_GetNeighbor(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_46gp_IsVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_Read(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_infile_name); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_Write(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name, PyObject *__pyx_v_mode); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_Embed(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_embedFlags); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_copy_of_orig_graph, int __pyx_v_embed_result); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ static PyObject *__pyx_tp_new_9planarity_4full_5graph_Graph(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ @@ -2534,8 +2538,8 @@ typedef struct { __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; - PyObject *__pyx_codeobj_tab[39]; - PyObject *__pyx_string_tab[224]; + PyObject *__pyx_codeobj_tab[38]; + PyObject *__pyx_string_tab[221]; PyObject *__pyx_number_tab[1]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ @@ -2629,50 +2633,50 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati #define __pyx_kp_u_planarity_full_graph_pyx __pyx_string_tab[49] #define __pyx_kp_u_stringsource __pyx_string_tab[50] #define __pyx_kp_u_with_ulink __pyx_string_tab[51] -#define __pyx_n_u_EMBEDFLAGS_DRAWPLANAR __pyx_string_tab[52] -#define __pyx_n_u_EMBEDFLAGS_OUTERPLANAR __pyx_string_tab[53] -#define __pyx_n_u_EMBEDFLAGS_PLANAR __pyx_string_tab[54] -#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK23 __pyx_string_tab[55] -#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK33 __pyx_string_tab[56] -#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK4 __pyx_string_tab[57] -#define __pyx_n_u_FileName __pyx_string_tab[58] -#define __pyx_n_u_Graph __pyx_string_tab[59] -#define __pyx_n_u_Graph___reduce_cython __pyx_string_tab[60] -#define __pyx_n_u_Graph___setstate_cython __pyx_string_tab[61] -#define __pyx_n_u_Graph_gp_AddEdge __pyx_string_tab[62] -#define __pyx_n_u_Graph_gp_CopyGraph __pyx_string_tab[63] -#define __pyx_n_u_Graph_gp_DeleteEdge __pyx_string_tab[64] -#define __pyx_n_u_Graph_gp_DrawPlanar_RenderToFile __pyx_string_tab[65] -#define __pyx_n_u_Graph_gp_DrawPlanar_RenderToStri __pyx_string_tab[66] -#define __pyx_n_u_Graph_gp_DupGraph __pyx_string_tab[67] -#define __pyx_n_u_Graph_gp_EdgeArraySize __pyx_string_tab[68] -#define __pyx_n_u_Graph_gp_EdgeArrayStart __pyx_string_tab[69] -#define __pyx_n_u_Graph_gp_EdgeInUse __pyx_string_tab[70] -#define __pyx_n_u_Graph_gp_EdgeInUseArraySize __pyx_string_tab[71] -#define __pyx_n_u_Graph_gp_Embed __pyx_string_tab[72] -#define __pyx_n_u_Graph_gp_EnsureEdgeCapacity __pyx_string_tab[73] -#define __pyx_n_u_Graph_gp_ExtendWith_DrawPlanar __pyx_string_tab[74] -#define __pyx_n_u_Graph_gp_ExtendWith_K23Search __pyx_string_tab[75] -#define __pyx_n_u_Graph_gp_ExtendWith_K33Search __pyx_string_tab[76] -#define __pyx_n_u_Graph_gp_ExtendWith_K4Search __pyx_string_tab[77] -#define __pyx_n_u_Graph_gp_ExtendWith_Outerplanari __pyx_string_tab[78] -#define __pyx_n_u_Graph_gp_ExtendWith_Planarity __pyx_string_tab[79] -#define __pyx_n_u_Graph_gp_FindEdge __pyx_string_tab[80] -#define __pyx_n_u_Graph_gp_GetEdgeCapacity __pyx_string_tab[81] -#define __pyx_n_u_Graph_gp_GetFirstEdge __pyx_string_tab[82] -#define __pyx_n_u_Graph_gp_GetFirstVertex __pyx_string_tab[83] -#define __pyx_n_u_Graph_gp_GetLastVertex __pyx_string_tab[84] -#define __pyx_n_u_Graph_gp_GetN __pyx_string_tab[85] -#define __pyx_n_u_Graph_gp_GetNeighbor __pyx_string_tab[86] -#define __pyx_n_u_Graph_gp_GetNextEdge __pyx_string_tab[87] -#define __pyx_n_u_Graph_gp_GetVertexDegree __pyx_string_tab[88] -#define __pyx_n_u_Graph_gp_InitGraph __pyx_string_tab[89] -#define __pyx_n_u_Graph_gp_IsEdge __pyx_string_tab[90] -#define __pyx_n_u_Graph_gp_IsVertex __pyx_string_tab[91] -#define __pyx_n_u_Graph_gp_Read __pyx_string_tab[92] -#define __pyx_n_u_Graph_gp_ReinitializeGraph __pyx_string_tab[93] -#define __pyx_n_u_Graph_gp_TestEmbedResultIntegrit __pyx_string_tab[94] -#define __pyx_n_u_Graph_gp_VertexInRangeAscending __pyx_string_tab[95] +#define __pyx_n_u_AT_EDGE_CAPACITY_LIMIT __pyx_string_tab[52] +#define __pyx_n_u_EMBEDFLAGS_DRAWPLANAR __pyx_string_tab[53] +#define __pyx_n_u_EMBEDFLAGS_OUTERPLANAR __pyx_string_tab[54] +#define __pyx_n_u_EMBEDFLAGS_PLANAR __pyx_string_tab[55] +#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK23 __pyx_string_tab[56] +#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK33 __pyx_string_tab[57] +#define __pyx_n_u_EMBEDFLAGS_SEARCHFORK4 __pyx_string_tab[58] +#define __pyx_n_u_FileName __pyx_string_tab[59] +#define __pyx_n_u_Graph __pyx_string_tab[60] +#define __pyx_n_u_Graph___reduce_cython __pyx_string_tab[61] +#define __pyx_n_u_Graph___setstate_cython __pyx_string_tab[62] +#define __pyx_n_u_Graph_gp_AddEdge __pyx_string_tab[63] +#define __pyx_n_u_Graph_gp_CopyGraph __pyx_string_tab[64] +#define __pyx_n_u_Graph_gp_DeleteEdge __pyx_string_tab[65] +#define __pyx_n_u_Graph_gp_DrawPlanar_RenderToFile __pyx_string_tab[66] +#define __pyx_n_u_Graph_gp_DrawPlanar_RenderToStri __pyx_string_tab[67] +#define __pyx_n_u_Graph_gp_DupGraph __pyx_string_tab[68] +#define __pyx_n_u_Graph_gp_EdgeInUse __pyx_string_tab[69] +#define __pyx_n_u_Graph_gp_Embed __pyx_string_tab[70] +#define __pyx_n_u_Graph_gp_EnsureEdgeCapacity __pyx_string_tab[71] +#define __pyx_n_u_Graph_gp_ExtendWith_DrawPlanar __pyx_string_tab[72] +#define __pyx_n_u_Graph_gp_ExtendWith_K23Search __pyx_string_tab[73] +#define __pyx_n_u_Graph_gp_ExtendWith_K33Search __pyx_string_tab[74] +#define __pyx_n_u_Graph_gp_ExtendWith_K4Search __pyx_string_tab[75] +#define __pyx_n_u_Graph_gp_ExtendWith_Outerplanari __pyx_string_tab[76] +#define __pyx_n_u_Graph_gp_ExtendWith_Planarity __pyx_string_tab[77] +#define __pyx_n_u_Graph_gp_FindEdge __pyx_string_tab[78] +#define __pyx_n_u_Graph_gp_GetEdgeCapacity __pyx_string_tab[79] +#define __pyx_n_u_Graph_gp_GetFirstEdge __pyx_string_tab[80] +#define __pyx_n_u_Graph_gp_GetN __pyx_string_tab[81] +#define __pyx_n_u_Graph_gp_GetNeighbor __pyx_string_tab[82] +#define __pyx_n_u_Graph_gp_GetNextEdge __pyx_string_tab[83] +#define __pyx_n_u_Graph_gp_GetVertexDegree __pyx_string_tab[84] +#define __pyx_n_u_Graph_gp_InitGraph __pyx_string_tab[85] +#define __pyx_n_u_Graph_gp_IsEdge __pyx_string_tab[86] +#define __pyx_n_u_Graph_gp_IsVertex __pyx_string_tab[87] +#define __pyx_n_u_Graph_gp_LowerBoundEdgeStorage __pyx_string_tab[88] +#define __pyx_n_u_Graph_gp_LowerBoundVertices __pyx_string_tab[89] +#define __pyx_n_u_Graph_gp_Read __pyx_string_tab[90] +#define __pyx_n_u_Graph_gp_ReinitGraph __pyx_string_tab[91] +#define __pyx_n_u_Graph_gp_TestEmbedResultIntegrit __pyx_string_tab[92] +#define __pyx_n_u_Graph_gp_UpperBoundEdgeStorage __pyx_string_tab[93] +#define __pyx_n_u_Graph_gp_UpperBoundEdges __pyx_string_tab[94] +#define __pyx_n_u_Graph_gp_UpperBoundVertices __pyx_string_tab[95] #define __pyx_n_u_Graph_gp_Write __pyx_string_tab[96] #define __pyx_n_u_NIL __pyx_string_tab[97] #define __pyx_n_u_NONEMBEDDABLE __pyx_string_tab[98] @@ -2698,109 +2702,106 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati #define __pyx_n_u_gp_DrawPlanar_RenderToFile __pyx_string_tab[118] #define __pyx_n_u_gp_DrawPlanar_RenderToString __pyx_string_tab[119] #define __pyx_n_u_gp_DupGraph __pyx_string_tab[120] -#define __pyx_n_u_gp_EdgeArraySize __pyx_string_tab[121] -#define __pyx_n_u_gp_EdgeArrayStart __pyx_string_tab[122] -#define __pyx_n_u_gp_EdgeInUse __pyx_string_tab[123] -#define __pyx_n_u_gp_EdgeInUseArraySize __pyx_string_tab[124] -#define __pyx_n_u_gp_Embed __pyx_string_tab[125] -#define __pyx_n_u_gp_EnsureEdgeCapacity __pyx_string_tab[126] -#define __pyx_n_u_gp_ExtendWith_DrawPlanar __pyx_string_tab[127] -#define __pyx_n_u_gp_ExtendWith_K23Search __pyx_string_tab[128] -#define __pyx_n_u_gp_ExtendWith_K33Search __pyx_string_tab[129] -#define __pyx_n_u_gp_ExtendWith_K4Search __pyx_string_tab[130] -#define __pyx_n_u_gp_ExtendWith_Outerplanarity __pyx_string_tab[131] -#define __pyx_n_u_gp_ExtendWith_Planarity __pyx_string_tab[132] -#define __pyx_n_u_gp_FindEdge __pyx_string_tab[133] -#define __pyx_n_u_gp_GetEdgeCapacity __pyx_string_tab[134] -#define __pyx_n_u_gp_GetFirstEdge __pyx_string_tab[135] -#define __pyx_n_u_gp_GetFirstVertex __pyx_string_tab[136] -#define __pyx_n_u_gp_GetLastVertex __pyx_string_tab[137] -#define __pyx_n_u_gp_GetLibPlanarityVersionFull __pyx_string_tab[138] -#define __pyx_n_u_gp_GetN __pyx_string_tab[139] -#define __pyx_n_u_gp_GetNeighbor __pyx_string_tab[140] -#define __pyx_n_u_gp_GetNextEdge __pyx_string_tab[141] -#define __pyx_n_u_gp_GetProjectVersionFull __pyx_string_tab[142] -#define __pyx_n_u_gp_GetVertexDegree __pyx_string_tab[143] -#define __pyx_n_u_gp_InitGraph __pyx_string_tab[144] -#define __pyx_n_u_gp_IsEdge __pyx_string_tab[145] -#define __pyx_n_u_gp_IsVertex __pyx_string_tab[146] -#define __pyx_n_u_gp_Read __pyx_string_tab[147] -#define __pyx_n_u_gp_ReinitializeGraph __pyx_string_tab[148] -#define __pyx_n_u_gp_TestEmbedResultIntegrity __pyx_string_tab[149] -#define __pyx_n_u_gp_VertexInRangeAscending __pyx_string_tab[150] -#define __pyx_n_u_gp_Write __pyx_string_tab[151] -#define __pyx_n_u_infile_name __pyx_string_tab[152] -#define __pyx_n_u_int __pyx_string_tab[153] -#define __pyx_n_u_is_coroutine __pyx_string_tab[154] -#define __pyx_n_u_items __pyx_string_tab[155] -#define __pyx_n_u_m __pyx_string_tab[156] -#define __pyx_n_u_main __pyx_string_tab[157] -#define __pyx_n_u_mode __pyx_string_tab[158] -#define __pyx_n_u_mode_code __pyx_string_tab[159] -#define __pyx_n_u_module __pyx_string_tab[160] -#define __pyx_n_u_n __pyx_string_tab[161] -#define __pyx_n_u_name __pyx_string_tab[162] -#define __pyx_n_u_new_edge_capacity __pyx_string_tab[163] -#define __pyx_n_u_new_graph __pyx_string_tab[164] -#define __pyx_n_u_outfile_name __pyx_string_tab[165] -#define __pyx_n_u_planarity_full_graph __pyx_string_tab[166] -#define __pyx_n_u_pop __pyx_string_tab[167] -#define __pyx_n_u_pyx_state __pyx_string_tab[168] -#define __pyx_n_u_qualname __pyx_string_tab[169] -#define __pyx_n_u_reduce __pyx_string_tab[170] -#define __pyx_n_u_reduce_cython __pyx_string_tab[171] -#define __pyx_n_u_reduce_ex __pyx_string_tab[172] -#define __pyx_n_u_renditionString __pyx_string_tab[173] -#define __pyx_n_u_return __pyx_string_tab[174] -#define __pyx_n_u_self __pyx_string_tab[175] -#define __pyx_n_u_set_name __pyx_string_tab[176] -#define __pyx_n_u_setdefault __pyx_string_tab[177] -#define __pyx_n_u_setstate __pyx_string_tab[178] -#define __pyx_n_u_setstate_cython __pyx_string_tab[179] -#define __pyx_n_u_src_graph __pyx_string_tab[180] -#define __pyx_n_u_src_graph_uninit_error __pyx_string_tab[181] -#define __pyx_n_u_string_conversion_error __pyx_string_tab[182] -#define __pyx_n_u_test __pyx_string_tab[183] -#define __pyx_n_u_theFileName __pyx_string_tab[184] -#define __pyx_n_u_theGraph_dup __pyx_string_tab[185] -#define __pyx_n_u_u __pyx_string_tab[186] -#define __pyx_n_u_ulink __pyx_string_tab[187] -#define __pyx_n_u_v __pyx_string_tab[188] -#define __pyx_n_u_values __pyx_string_tab[189] -#define __pyx_n_u_vlink __pyx_string_tab[190] -#define __pyx_kp_b_iso88591_4_Q_aq_Q __pyx_string_tab[191] -#define __pyx_kp_b_iso88591_A_1D __pyx_string_tab[192] -#define __pyx_kp_b_iso88591_A_1D_Cq_aq __pyx_string_tab[193] +#define __pyx_n_u_gp_EdgeInUse __pyx_string_tab[121] +#define __pyx_n_u_gp_Embed __pyx_string_tab[122] +#define __pyx_n_u_gp_EnsureEdgeCapacity __pyx_string_tab[123] +#define __pyx_n_u_gp_ExtendWith_DrawPlanar __pyx_string_tab[124] +#define __pyx_n_u_gp_ExtendWith_K23Search __pyx_string_tab[125] +#define __pyx_n_u_gp_ExtendWith_K33Search __pyx_string_tab[126] +#define __pyx_n_u_gp_ExtendWith_K4Search __pyx_string_tab[127] +#define __pyx_n_u_gp_ExtendWith_Outerplanarity __pyx_string_tab[128] +#define __pyx_n_u_gp_ExtendWith_Planarity __pyx_string_tab[129] +#define __pyx_n_u_gp_FindEdge __pyx_string_tab[130] +#define __pyx_n_u_gp_GetEdgeCapacity __pyx_string_tab[131] +#define __pyx_n_u_gp_GetFirstEdge __pyx_string_tab[132] +#define __pyx_n_u_gp_GetLibPlanarityVersionFull __pyx_string_tab[133] +#define __pyx_n_u_gp_GetN __pyx_string_tab[134] +#define __pyx_n_u_gp_GetNeighbor __pyx_string_tab[135] +#define __pyx_n_u_gp_GetNextEdge __pyx_string_tab[136] +#define __pyx_n_u_gp_GetProjectVersionFull __pyx_string_tab[137] +#define __pyx_n_u_gp_GetVertexDegree __pyx_string_tab[138] +#define __pyx_n_u_gp_InitGraph __pyx_string_tab[139] +#define __pyx_n_u_gp_IsEdge __pyx_string_tab[140] +#define __pyx_n_u_gp_IsVertex __pyx_string_tab[141] +#define __pyx_n_u_gp_LowerBoundEdgeStorage __pyx_string_tab[142] +#define __pyx_n_u_gp_LowerBoundVertices __pyx_string_tab[143] +#define __pyx_n_u_gp_Read __pyx_string_tab[144] +#define __pyx_n_u_gp_ReinitGraph __pyx_string_tab[145] +#define __pyx_n_u_gp_TestEmbedResultIntegrity __pyx_string_tab[146] +#define __pyx_n_u_gp_UpperBoundEdgeStorage __pyx_string_tab[147] +#define __pyx_n_u_gp_UpperBoundEdges __pyx_string_tab[148] +#define __pyx_n_u_gp_UpperBoundVertices __pyx_string_tab[149] +#define __pyx_n_u_gp_Write __pyx_string_tab[150] +#define __pyx_n_u_infile_name __pyx_string_tab[151] +#define __pyx_n_u_int __pyx_string_tab[152] +#define __pyx_n_u_is_coroutine __pyx_string_tab[153] +#define __pyx_n_u_items __pyx_string_tab[154] +#define __pyx_n_u_m __pyx_string_tab[155] +#define __pyx_n_u_main __pyx_string_tab[156] +#define __pyx_n_u_mode __pyx_string_tab[157] +#define __pyx_n_u_mode_code __pyx_string_tab[158] +#define __pyx_n_u_module __pyx_string_tab[159] +#define __pyx_n_u_n __pyx_string_tab[160] +#define __pyx_n_u_name __pyx_string_tab[161] +#define __pyx_n_u_new_edge_capacity __pyx_string_tab[162] +#define __pyx_n_u_new_graph __pyx_string_tab[163] +#define __pyx_n_u_outfile_name __pyx_string_tab[164] +#define __pyx_n_u_planarity_full_graph __pyx_string_tab[165] +#define __pyx_n_u_pop __pyx_string_tab[166] +#define __pyx_n_u_pyx_state __pyx_string_tab[167] +#define __pyx_n_u_qualname __pyx_string_tab[168] +#define __pyx_n_u_reduce __pyx_string_tab[169] +#define __pyx_n_u_reduce_cython __pyx_string_tab[170] +#define __pyx_n_u_reduce_ex __pyx_string_tab[171] +#define __pyx_n_u_renditionString __pyx_string_tab[172] +#define __pyx_n_u_return __pyx_string_tab[173] +#define __pyx_n_u_self __pyx_string_tab[174] +#define __pyx_n_u_set_name __pyx_string_tab[175] +#define __pyx_n_u_setdefault __pyx_string_tab[176] +#define __pyx_n_u_setstate __pyx_string_tab[177] +#define __pyx_n_u_setstate_cython __pyx_string_tab[178] +#define __pyx_n_u_src_graph __pyx_string_tab[179] +#define __pyx_n_u_src_graph_uninit_error __pyx_string_tab[180] +#define __pyx_n_u_string_conversion_error __pyx_string_tab[181] +#define __pyx_n_u_test __pyx_string_tab[182] +#define __pyx_n_u_theFileName __pyx_string_tab[183] +#define __pyx_n_u_theGraph_dup __pyx_string_tab[184] +#define __pyx_n_u_u __pyx_string_tab[185] +#define __pyx_n_u_ulink __pyx_string_tab[186] +#define __pyx_n_u_v __pyx_string_tab[187] +#define __pyx_n_u_values __pyx_string_tab[188] +#define __pyx_n_u_vlink __pyx_string_tab[189] +#define __pyx_kp_b_iso88591_4_Q_aq_Q __pyx_string_tab[190] +#define __pyx_kp_b_iso88591_A_1D __pyx_string_tab[191] +#define __pyx_kp_b_iso88591_A_1D_Cq_aq __pyx_string_tab[192] +#define __pyx_kp_b_iso88591_A_1_a __pyx_string_tab[193] #define __pyx_kp_b_iso88591_A_1_l_Q_aq __pyx_string_tab[194] #define __pyx_kp_b_iso88591_A_4_NcQR_a_1 __pyx_string_tab[195] #define __pyx_kp_b_iso88591_A_4_Q_a_y_3a_j_q_A_4xs_Yha_A_M_l __pyx_string_tab[196] -#define __pyx_kp_b_iso88591_A_4q __pyx_string_tab[197] -#define __pyx_kp_b_iso88591_A_4t_Qa_a_8_at_q __pyx_string_tab[198] -#define __pyx_kp_b_iso88591_A_4t_Qa_a_Qa_Qd_a __pyx_string_tab[199] -#define __pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L __pyx_string_tab[200] -#define __pyx_kp_b_iso88591_A_4t_q_a_B_1 __pyx_string_tab[201] -#define __pyx_kp_b_iso88591_A_4t_q_as_1_1D_A __pyx_string_tab[202] -#define __pyx_kp_b_iso88591_A_4t_q_as_1_4t_q_as_1_AT_S __pyx_string_tab[203] -#define __pyx_kp_b_iso88591_A_6_Bd_1_a_1_6_Bd_1_a_1_Kq_L_7_W __pyx_string_tab[204] -#define __pyx_kp_b_iso88591_A_AT_S_aq __pyx_string_tab[205] -#define __pyx_kp_b_iso88591_A_M_l_S_aq __pyx_string_tab[206] +#define __pyx_kp_b_iso88591_A_4t_Qa_a_8_at_q __pyx_string_tab[197] +#define __pyx_kp_b_iso88591_A_4t_Qa_a_Qa_Qd_a __pyx_string_tab[198] +#define __pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L __pyx_string_tab[199] +#define __pyx_kp_b_iso88591_A_4t_q_a_B_1 __pyx_string_tab[200] +#define __pyx_kp_b_iso88591_A_4t_q_as_1_1D_A __pyx_string_tab[201] +#define __pyx_kp_b_iso88591_A_4t_q_as_1_4t_q_as_1_AT_S __pyx_string_tab[202] +#define __pyx_kp_b_iso88591_A_6_Bd_1_a_1_6_Bd_1_a_1_Kq_L_7_W __pyx_string_tab[203] +#define __pyx_kp_b_iso88591_A_AT_S_aq __pyx_string_tab[204] +#define __pyx_kp_b_iso88591_A_M_l_S_aq __pyx_string_tab[205] +#define __pyx_kp_b_iso88591_A_Q __pyx_string_tab[206] #define __pyx_kp_b_iso88591_A_Q_1_l_CTTWWX_aq_A_a __pyx_string_tab[207] #define __pyx_kp_b_iso88591_A_Qd_c_aq __pyx_string_tab[208] #define __pyx_kp_b_iso88591_A_Y_0_S_E_A_m5_1_4q_A_31A_q_IQd __pyx_string_tab[209] -#define __pyx_kp_b_iso88591_A_a __pyx_string_tab[210] -#define __pyx_kp_b_iso88591_A_at1 __pyx_string_tab[211] -#define __pyx_kp_b_iso88591_A_at1_2 __pyx_string_tab[212] -#define __pyx_kp_b_iso88591_A_c_s_q_L __pyx_string_tab[213] -#define __pyx_kp_b_iso88591_A_q_A_HAT_Zs_aq __pyx_string_tab[214] -#define __pyx_kp_b_iso88591_A_q_q_L_SPQ_a_EQa __pyx_string_tab[215] -#define __pyx_kp_b_iso88591_A_s_A_r_d_q_L __pyx_string_tab[216] -#define __pyx_kp_b_iso88591_A_s_A_s_t1_l __pyx_string_tab[217] -#define __pyx_kp_b_iso88591_C1 __pyx_string_tab[218] -#define __pyx_kp_b_iso88591_H __pyx_string_tab[219] -#define __pyx_kp_b_iso88591_Q __pyx_string_tab[220] -#define __pyx_kp_b_iso88591_Q_6l_4q_1_Qa_uA_9A_a_q __pyx_string_tab[221] -#define __pyx_kp_b_iso88591_YYZ_A_L_2_a_3d_s_aq_q __pyx_string_tab[222] -#define __pyx_kp_b_iso88591_l_3d_s_aq_q __pyx_string_tab[223] +#define __pyx_kp_b_iso88591_A_at1 __pyx_string_tab[210] +#define __pyx_kp_b_iso88591_A_q_A_HAT_Zs_aq __pyx_string_tab[211] +#define __pyx_kp_b_iso88591_A_q_q_L_SPQ_a_EQa __pyx_string_tab[212] +#define __pyx_kp_b_iso88591_A_s_D_r_4q_l __pyx_string_tab[213] +#define __pyx_kp_b_iso88591_A_s_t1_r_d_q_L __pyx_string_tab[214] +#define __pyx_kp_b_iso88591_C1 __pyx_string_tab[215] +#define __pyx_kp_b_iso88591_H __pyx_string_tab[216] +#define __pyx_kp_b_iso88591_Q __pyx_string_tab[217] +#define __pyx_kp_b_iso88591_Q_6l_4q_1_Qa_uA_9A_a_q __pyx_string_tab[218] +#define __pyx_kp_b_iso88591_YYZ_A_L_2_a_3d_s_aq_q __pyx_string_tab[219] +#define __pyx_kp_b_iso88591_l_3d_s_aq_q __pyx_string_tab[220] #define __pyx_int_0 __pyx_number_tab[0] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE @@ -2818,8 +2819,8 @@ static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { #endif Py_CLEAR(clear_module_state->__pyx_ptype_9planarity_4full_5graph_Graph); Py_CLEAR(clear_module_state->__pyx_type_9planarity_4full_5graph_Graph); - for (int i=0; i<39; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<224; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } + for (int i=0; i<38; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<221; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ @@ -2845,8 +2846,8 @@ static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); Py_VISIT(traverse_module_state->__pyx_ptype_9planarity_4full_5graph_Graph); Py_VISIT(traverse_module_state->__pyx_type_9planarity_4full_5graph_Graph); - for (int i=0; i<39; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<224; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } + for (int i=0; i<38; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<221; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ @@ -2861,238 +2862,76 @@ return 0; #endif /* #### Code section: module_code ### */ -/* "planarity/full/graph.pyx":28 +/* "planarity/full/graph.pyx":30 * - * - * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() - * return encoded_version.decode('utf-8') + * cdef class Graph: + * def __cinit__(self): # <<<<<<<<<<<<<< + * global global_id_count + * self._theGraph = cgraphLib.gp_New() */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_gp_GetProjectVersionFull, "gp_GetProjectVersionFull()"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_1gp_GetProjectVersionFull = {"gp_GetProjectVersionFull", (PyCFunction)__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull, METH_NOARGS, __pyx_doc_9planarity_4full_5graph_gp_GetProjectVersionFull}; -static PyObject *__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { +static int __pyx_pw_9planarity_4full_5graph_5Graph_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_9planarity_4full_5graph_5Graph_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetProjectVersionFull (wrapper)", 0); + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; + #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); - __pyx_r = __pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(__pyx_self); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, __pyx_nargs); return -1; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return -1; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__cinit__", __pyx_kwds); return -1;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_v_encoded_version = 0; - PyObject *__pyx_r = NULL; +static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + int __pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetProjectVersionFull", 0); + __Pyx_RefNannySetupContext("__cinit__", 0); - /* "planarity/full/graph.pyx":29 - * - * def gp_GetProjectVersionFull(): - * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() # <<<<<<<<<<<<<< - * return encoded_version.decode('utf-8') - * + /* "planarity/full/graph.pyx":32 + * def __cinit__(self): + * global global_id_count + * self._theGraph = cgraphLib.gp_New() # <<<<<<<<<<<<<< + * if self._theGraph == NULL: + * raise MemoryError("gp_New() failed.") */ - __pyx_t_1 = __Pyx_PyBytes_FromString(gp_GetProjectVersionFull()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_encoded_version = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_v_self->_theGraph = gp_New(); - /* "planarity/full/graph.pyx":30 - * def gp_GetProjectVersionFull(): - * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() - * return encoded_version.decode('utf-8') # <<<<<<<<<<<<<< - * + /* "planarity/full/graph.pyx":33 + * global global_id_count + * self._theGraph = cgraphLib.gp_New() + * if self._theGraph == NULL: # <<<<<<<<<<<<<< + * raise MemoryError("gp_New() failed.") * */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_encoded_version, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":28 - * + /* "planarity/full/graph.pyx":34 + * self._theGraph = cgraphLib.gp_New() + * if self._theGraph == NULL: + * raise MemoryError("gp_New() failed.") # <<<<<<<<<<<<<< * - * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() - * return encoded_version.decode('utf-8') -*/ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.gp_GetProjectVersionFull", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_encoded_version); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":33 - * - * - * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() - * return encoded_version.decode('utf-8') -*/ - -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull, "gp_GetLibPlanarityVersionFull()"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull = {"gp_GetLibPlanarityVersionFull", (PyCFunction)__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull, METH_NOARGS, __pyx_doc_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull}; -static PyObject *__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetLibPlanarityVersionFull (wrapper)", 0); - __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); - __pyx_r = __pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_v_encoded_version = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetLibPlanarityVersionFull", 0); - - /* "planarity/full/graph.pyx":34 - * - * def gp_GetLibPlanarityVersionFull(): - * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() # <<<<<<<<<<<<<< - * return encoded_version.decode('utf-8') - * -*/ - __pyx_t_1 = __Pyx_PyBytes_FromString(gp_GetLibPlanarityVersionFull()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_encoded_version = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "planarity/full/graph.pyx":35 - * def gp_GetLibPlanarityVersionFull(): - * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() - * return encoded_version.decode('utf-8') # <<<<<<<<<<<<<< - * - * -*/ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_encoded_version, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "planarity/full/graph.pyx":33 - * - * - * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() - * return encoded_version.decode('utf-8') -*/ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.gp_GetLibPlanarityVersionFull", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_encoded_version); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":39 - * - * cdef class Graph: - * def __cinit__(self): # <<<<<<<<<<<<<< - * global global_id_count - * self._theGraph = cgraphLib.gp_New() -*/ - -/* Python wrapper */ -static int __pyx_pw_9planarity_4full_5graph_5Graph_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_9planarity_4full_5graph_5Graph_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; - #endif - __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, __pyx_nargs); return -1; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return -1; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__cinit__", __pyx_kwds); return -1;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "planarity/full/graph.pyx":41 - * def __cinit__(self): - * global global_id_count - * self._theGraph = cgraphLib.gp_New() # <<<<<<<<<<<<<< - * if self._theGraph == NULL: - * raise MemoryError("gp_New() failed.") -*/ - __pyx_v_self->_theGraph = gp_New(); - - /* "planarity/full/graph.pyx":42 - * global global_id_count - * self._theGraph = cgraphLib.gp_New() - * if self._theGraph == NULL: # <<<<<<<<<<<<<< - * raise MemoryError("gp_New() failed.") - * -*/ - __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); - if (unlikely(__pyx_t_1)) { - - /* "planarity/full/graph.pyx":43 - * self._theGraph = cgraphLib.gp_New() - * if self._theGraph == NULL: - * raise MemoryError("gp_New() failed.") # <<<<<<<<<<<<<< - * - * def __dealloc__(self): + * def __dealloc__(self): */ __pyx_t_3 = NULL; __pyx_t_4 = 1; @@ -3100,14 +2939,14 @@ static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9p PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_New_failed}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_MemoryError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 43, __pyx_L1_error) + __PYX_ERR(0, 34, __pyx_L1_error) - /* "planarity/full/graph.pyx":42 + /* "planarity/full/graph.pyx":33 * global global_id_count * self._theGraph = cgraphLib.gp_New() * if self._theGraph == NULL: # <<<<<<<<<<<<<< @@ -3116,7 +2955,7 @@ static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9p */ } - /* "planarity/full/graph.pyx":39 + /* "planarity/full/graph.pyx":30 * * cdef class Graph: * def __cinit__(self): # <<<<<<<<<<<<<< @@ -3137,7 +2976,7 @@ static int __pyx_pf_9planarity_4full_5graph_5Graph___cinit__(struct __pyx_obj_9p return __pyx_r; } -/* "planarity/full/graph.pyx":45 +/* "planarity/full/graph.pyx":36 * raise MemoryError("gp_New() failed.") * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3161,7 +3000,7 @@ static void __pyx_pw_9planarity_4full_5graph_5Graph_3__dealloc__(PyObject *__pyx static void __pyx_pf_9planarity_4full_5graph_5Graph_2__dealloc__(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { int __pyx_t_1; - /* "planarity/full/graph.pyx":46 + /* "planarity/full/graph.pyx":37 * * def __dealloc__(self): * if self._theGraph != NULL: # <<<<<<<<<<<<<< @@ -3171,16 +3010,16 @@ static void __pyx_pf_9planarity_4full_5graph_5Graph_2__dealloc__(struct __pyx_ob __pyx_t_1 = (__pyx_v_self->_theGraph != NULL); if (__pyx_t_1) { - /* "planarity/full/graph.pyx":47 + /* "planarity/full/graph.pyx":38 * def __dealloc__(self): * if self._theGraph != NULL: * cgraphLib.gp_Free(&self._theGraph) # <<<<<<<<<<<<<< * - * def gp_IsEdge(self, int e): + * def gp_InitGraph(self, int n): */ gp_Free((&__pyx_v_self->_theGraph)); - /* "planarity/full/graph.pyx":46 + /* "planarity/full/graph.pyx":37 * * def __dealloc__(self): * if self._theGraph != NULL: # <<<<<<<<<<<<<< @@ -3189,7 +3028,7 @@ static void __pyx_pf_9planarity_4full_5graph_5Graph_2__dealloc__(struct __pyx_ob */ } - /* "planarity/full/graph.pyx":45 + /* "planarity/full/graph.pyx":36 * raise MemoryError("gp_New() failed.") * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3200,32 +3039,32 @@ static void __pyx_pf_9planarity_4full_5graph_5Graph_2__dealloc__(struct __pyx_ob /* function exit code */ } -/* "planarity/full/graph.pyx":49 +/* "planarity/full/graph.pyx":40 * cgraphLib.gp_Free(&self._theGraph) * - * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< - * return ( - * (e >= self.gp_EdgeArrayStart()) and + * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: + * raise RuntimeError(f"gp_InitGraph() failed.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_5gp_IsEdge(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_5gp_InitGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_4gp_IsEdge, "Graph.gp_IsEdge(self, int e)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_5gp_IsEdge = {"gp_IsEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_5gp_IsEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_4gp_IsEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_5gp_IsEdge(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_4gp_InitGraph, "Graph.gp_InitGraph(self, int n)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_5gp_InitGraph = {"gp_InitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_5gp_InitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_4gp_InitGraph}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_5gp_InitGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_e; + int __pyx_v_n; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -3236,7 +3075,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_IsEdge (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_InitGraph (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3246,45 +3085,45 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 49, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 40, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 49, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 40, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_IsEdge", 0) < (0)) __PYX_ERR(0, 49, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_InitGraph", 0) < (0)) __PYX_ERR(0, 40, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_IsEdge", 1, 1, 1, i); __PYX_ERR(0, 49, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_InitGraph", 1, 1, 1, i); __PYX_ERR(0, 40, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 49, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 40, __pyx_L3_error) } - __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L3_error) + __pyx_v_n = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_IsEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 49, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_InitGraph", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 40, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_InitGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_4gp_IsEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_4gp_InitGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_n); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -3294,126 +3133,82 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_4gp_IsEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_4gp_InitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_n) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; + int __pyx_t_4; size_t __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_IsEdge", 0); + __Pyx_RefNannySetupContext("gp_InitGraph", 0); - /* "planarity/full/graph.pyx":50 + /* "planarity/full/graph.pyx":41 + * + * def gp_InitGraph(self, int n): + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_InitGraph() failed.") * - * def gp_IsEdge(self, int e): - * return ( # <<<<<<<<<<<<<< - * (e >= self.gp_EdgeArrayStart()) and - * (e < self.gp_EdgeArraySize()) and -*/ - __Pyx_XDECREF(__pyx_r); - - /* "planarity/full/graph.pyx":51 - * def gp_IsEdge(self, int e): - * return ( - * (e >= self.gp_EdgeArrayStart()) and # <<<<<<<<<<<<<< - * (e < self.gp_EdgeArraySize()) and - * cgraphLib.gp_IsEdge(self._theGraph, e) */ - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_InitGraph(__pyx_v_self->_theGraph, __pyx_v_n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_5 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_EdgeArrayStart, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 51, __pyx_L1_error) - if (__pyx_t_6) { - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __Pyx_INCREF(__pyx_t_4); - __pyx_t_1 = __pyx_t_4; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L3_bool_binop_done; - } + if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":52 - * return ( - * (e >= self.gp_EdgeArrayStart()) and - * (e < self.gp_EdgeArraySize()) and # <<<<<<<<<<<<<< - * cgraphLib.gp_IsEdge(self._theGraph, e) - * ) + /* "planarity/full/graph.pyx":42 + * def gp_InitGraph(self, int n): + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: + * raise RuntimeError(f"gp_InitGraph() failed.") # <<<<<<<<<<<<<< + * + * def gp_ReinitGraph(self): */ - __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_5 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_EdgeArraySize, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 52, __pyx_L1_error) - if (__pyx_t_6) { - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = __pyx_t_2; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L3_bool_binop_done; - } + __pyx_t_2 = NULL; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_gp_InitGraph_failed}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 42, __pyx_L1_error) - /* "planarity/full/graph.pyx":53 - * (e >= self.gp_EdgeArrayStart()) and - * (e < self.gp_EdgeArraySize()) and - * cgraphLib.gp_IsEdge(self._theGraph, e) # <<<<<<<<<<<<<< - * ) + /* "planarity/full/graph.pyx":41 + * + * def gp_InitGraph(self, int n): + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_InitGraph() failed.") * */ - __pyx_t_7 = gp_IsEdge(__pyx_v_self->_theGraph, __pyx_v_e); - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __pyx_t_2; - __pyx_t_2 = 0; - __pyx_L3_bool_binop_done:; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + } - /* "planarity/full/graph.pyx":49 + /* "planarity/full/graph.pyx":40 * cgraphLib.gp_Free(&self._theGraph) * - * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< - * return ( - * (e >= self.gp_EdgeArrayStart()) and + * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: + * raise RuntimeError(f"gp_InitGraph() failed.") */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_InitGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3421,25 +3216,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_4gp_IsEdge(struct __pyx return __pyx_r; } -/* "planarity/full/graph.pyx":56 - * ) +/* "planarity/full/graph.pyx":44 + * raise RuntimeError(f"gp_InitGraph() failed.") * - * def gp_EdgeArrayStart(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) + * def gp_ReinitGraph(self): # <<<<<<<<<<<<<< + * cgraphLib.gp_ReinitGraph(self._theGraph) * */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_7gp_ReinitGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart, "Graph.gp_EdgeArrayStart(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart = {"gp_EdgeArrayStart", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_6gp_ReinitGraph, "Graph.gp_ReinitGraph(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_7gp_ReinitGraph = {"gp_ReinitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_7gp_ReinitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_6gp_ReinitGraph}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_7gp_ReinitGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -3452,7 +3247,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_EdgeArrayStart (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_ReinitGraph (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3461,85 +3256,72 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_EdgeArrayStart", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ReinitGraph", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_EdgeArrayStart", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ReinitGraph", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_6gp_ReinitGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_6gp_ReinitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_EdgeArrayStart", 0); + __Pyx_RefNannySetupContext("gp_ReinitGraph", 0); - /* "planarity/full/graph.pyx":57 + /* "planarity/full/graph.pyx":45 * - * def gp_EdgeArrayStart(self): - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) # <<<<<<<<<<<<<< + * def gp_ReinitGraph(self): + * cgraphLib.gp_ReinitGraph(self._theGraph) # <<<<<<<<<<<<<< * - * def gp_EdgeInUse(self, int e): + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_EdgeArrayStart(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + gp_ReinitGraph(__pyx_v_self->_theGraph); - /* "planarity/full/graph.pyx":56 - * ) + /* "planarity/full/graph.pyx":44 + * raise RuntimeError(f"gp_InitGraph() failed.") * - * def gp_EdgeArrayStart(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) + * def gp_ReinitGraph(self): # <<<<<<<<<<<<<< + * cgraphLib.gp_ReinitGraph(self._theGraph) * */ /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeArrayStart", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":59 - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) +/* "planarity/full/graph.pyx":47 + * cgraphLib.gp_ReinitGraph(self._theGraph) * - * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: * raise RuntimeError( */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EdgeInUse(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_8gp_EdgeInUse, "Graph.gp_EdgeInUse(self, int e)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_9gp_EdgeInUse = {"gp_EdgeInUse", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EdgeInUse, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_8gp_EdgeInUse}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EdgeInUse(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity, "Graph.gp_EnsureEdgeCapacity(self, int new_edge_capacity)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity = {"gp_EnsureEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_e; + int __pyx_v_new_edge_capacity; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -3550,7 +3332,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_EdgeInUse (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_EnsureEdgeCapacity (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3560,45 +3342,45 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_new_edge_capacity,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 59, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 47, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 59, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 47, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_EdgeInUse", 0) < (0)) __PYX_ERR(0, 59, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_EnsureEdgeCapacity", 0) < (0)) __PYX_ERR(0, 47, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_EdgeInUse", 1, 1, 1, i); __PYX_ERR(0, 59, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_EnsureEdgeCapacity", 1, 1, 1, i); __PYX_ERR(0, 47, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 59, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 47, __pyx_L3_error) } - __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error) + __pyx_v_new_edge_capacity = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_new_edge_capacity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_EdgeInUse", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_EnsureEdgeCapacity", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 47, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeInUse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EnsureEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_8gp_EdgeInUse(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_new_edge_capacity); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -3608,123 +3390,111 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_8gp_EdgeInUse(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_new_edge_capacity) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5[3]; + PyObject *__pyx_t_6 = NULL; + size_t __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_EdgeInUse", 0); + __Pyx_RefNannySetupContext("gp_EnsureEdgeCapacity", 0); - /* "planarity/full/graph.pyx":60 + /* "planarity/full/graph.pyx":48 * - * def gp_EdgeInUse(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: # <<<<<<<<<<<<<< * raise RuntimeError( - * f"gp_EdgeInUse() failed: invalid edge index '{e}'." + * "gp_EnsureEdgeCapacity() failed to set edge capacity to " */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 60, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_EnsureEdgeCapacity(__pyx_v_self->_theGraph, __pyx_v_new_edge_capacity)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 48, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":61 - * def gp_EdgeInUse(self, int e): - * if not self.gp_IsEdge(e): + /* "planarity/full/graph.pyx":49 + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_EdgeInUse() failed: invalid edge index '{e}'." - * ) + * "gp_EnsureEdgeCapacity() failed to set edge capacity to " + * f"{new_edge_capacity}.") */ - __pyx_t_3 = NULL; + __pyx_t_2 = NULL; - /* "planarity/full/graph.pyx":62 - * if not self.gp_IsEdge(e): + /* "planarity/full/graph.pyx":51 * raise RuntimeError( - * f"gp_EdgeInUse() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< - * ) + * "gp_EnsureEdgeCapacity() failed to set edge capacity to " + * f"{new_edge_capacity}.") # <<<<<<<<<<<<<< * + * def gp_GetEdgeCapacity(self): */ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_EdgeInUse_failed_invalid_edge; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 43 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = 1; + __pyx_t_1 = __Pyx_PyUnicode_From_int(__pyx_v_new_edge_capacity, 0, ' ', 'd'); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_gp_EnsureEdgeCapacity_failed_to; + __pyx_t_5[1] = __pyx_t_1; + __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u_; + + /* "planarity/full/graph.pyx":50 + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: + * raise RuntimeError( + * "gp_EnsureEdgeCapacity() failed to set edge capacity to " # <<<<<<<<<<<<<< + * f"{new_edge_capacity}.") + * +*/ + __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 55 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 1, 127); + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_6}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 49, __pyx_L1_error) - /* "planarity/full/graph.pyx":60 + /* "planarity/full/graph.pyx":48 * - * def gp_EdgeInUse(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: # <<<<<<<<<<<<<< * raise RuntimeError( - * f"gp_EdgeInUse() failed: invalid edge index '{e}'." + * "gp_EnsureEdgeCapacity() failed to set edge capacity to " */ } - /* "planarity/full/graph.pyx":65 - * ) - * - * return cgraphLib.gp_EdgeInUse(self._theGraph, e) # <<<<<<<<<<<<<< - * - * def gp_EdgeArraySize(self): -*/ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_EdgeInUse(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "planarity/full/graph.pyx":59 - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) + /* "planarity/full/graph.pyx":47 + * cgraphLib.gp_ReinitGraph(self._theGraph) * - * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: * raise RuntimeError( */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeInUse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EnsureEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3732,25 +3502,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_8gp_EdgeInUse(struct __ return __pyx_r; } -/* "planarity/full/graph.pyx":67 - * return cgraphLib.gp_EdgeInUse(self._theGraph, e) +/* "planarity/full/graph.pyx":53 + * f"{new_edge_capacity}.") * - * def gp_EdgeArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArraySize(self._theGraph) + * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize, "Graph.gp_EdgeArraySize(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize = {"gp_EdgeArraySize", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity, "Graph.gp_GetEdgeCapacity(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity = {"gp_GetEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -3763,7 +3533,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_EdgeArraySize (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetEdgeCapacity (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3772,52 +3542,52 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_EdgeArraySize", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetEdgeCapacity", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_EdgeArraySize", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetEdgeCapacity", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_EdgeArraySize", 0); + __Pyx_RefNannySetupContext("gp_GetEdgeCapacity", 0); - /* "planarity/full/graph.pyx":68 + /* "planarity/full/graph.pyx":54 * - * def gp_EdgeArraySize(self): - * return cgraphLib.gp_EdgeArraySize(self._theGraph) # <<<<<<<<<<<<<< + * def gp_GetEdgeCapacity(self): + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) # <<<<<<<<<<<<<< * - * def gp_EdgeInUseArraySize(self): + * def gp_GetN(self)-> int: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_EdgeArraySize(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetEdgeCapacity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":67 - * return cgraphLib.gp_EdgeInUse(self._theGraph, e) + /* "planarity/full/graph.pyx":53 + * f"{new_edge_capacity}.") * - * def gp_EdgeArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArraySize(self._theGraph) + * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeArraySize", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3825,25 +3595,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize(stru return __pyx_r; } -/* "planarity/full/graph.pyx":70 - * return cgraphLib.gp_EdgeArraySize(self._theGraph) - * - * def gp_EdgeInUseArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) +/* "planarity/full/graph.pyx":56 + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * + * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< + * """ + * Returns the number of vertices in the graph. */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_13gp_GetN(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize, "Graph.gp_EdgeInUseArraySize(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize = {"gp_EdgeInUseArraySize", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_12gp_GetN, "Graph.gp_GetN(self) -> int\n\nReturns the number of vertices in the graph."); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_13gp_GetN = {"gp_GetN", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_13gp_GetN, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_12gp_GetN}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_13gp_GetN(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -3856,7 +3626,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_EdgeInUseArraySize (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetN (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3865,52 +3635,96 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_EdgeInUseArraySize", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetN", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_EdgeInUseArraySize", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetN", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_12gp_GetN(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_12gp_GetN(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_EdgeInUseArraySize", 0); + __Pyx_RefNannySetupContext("gp_GetN", 0); - /* "planarity/full/graph.pyx":71 + /* "planarity/full/graph.pyx":60 + * Returns the number of vertices in the graph. + * """ + * if self._theGraph == NULL: # <<<<<<<<<<<<<< + * raise RuntimeError("Graph is not initialized.") * - * def gp_EdgeInUseArraySize(self): - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) # <<<<<<<<<<<<<< +*/ + __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); + if (unlikely(__pyx_t_1)) { + + /* "planarity/full/graph.pyx":61 + * """ + * if self._theGraph == NULL: + * raise RuntimeError("Graph is not initialized.") # <<<<<<<<<<<<<< * - * def gp_GetFirstEdge(self, int v): + * return cgraphLib.gp_GetN(self._theGraph) +*/ + __pyx_t_3 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Graph_is_not_initialized}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 61, __pyx_L1_error) + + /* "planarity/full/graph.pyx":60 + * Returns the number of vertices in the graph. + * """ + * if self._theGraph == NULL: # <<<<<<<<<<<<<< + * raise RuntimeError("Graph is not initialized.") + * +*/ + } + + /* "planarity/full/graph.pyx":63 + * raise RuntimeError("Graph is not initialized.") + * + * return cgraphLib.gp_GetN(self._theGraph) # <<<<<<<<<<<<<< + * + * def gp_CopyGraph(self, Graph src_graph): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_EdgeInUseArraySize(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_2 = __Pyx_PyLong_From_int(gp_GetN(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_r = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":70 - * return cgraphLib.gp_EdgeArraySize(self._theGraph) - * - * def gp_EdgeInUseArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) + /* "planarity/full/graph.pyx":56 + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * + * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< + * """ + * Returns the number of vertices in the graph. */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeInUseArraySize", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetN", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3918,32 +3732,32 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize return __pyx_r; } -/* "planarity/full/graph.pyx":73 - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) +/* "planarity/full/graph.pyx":65 + * return cgraphLib.gp_GetN(self._theGraph) * - * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError( + * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< + * # NOTE: this is interpreting the self as the dstGraph, i.e. copying + * # the Graph wrapper that is passed in as the srcGraph */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_15gp_CopyGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge, "Graph.gp_GetFirstEdge(self, int v)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge = {"gp_GetFirstEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_14gp_CopyGraph, "Graph.gp_CopyGraph(self, Graph src_graph)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_15gp_CopyGraph = {"gp_CopyGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_15gp_CopyGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_14gp_CopyGraph}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_15gp_CopyGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_v; + struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -3954,7 +3768,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetFirstEdge (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_CopyGraph (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -3964,433 +3778,487 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_src_graph,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 73, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 65, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 73, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 65, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetFirstEdge", 0) < (0)) __PYX_ERR(0, 73, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_CopyGraph", 0) < (0)) __PYX_ERR(0, 65, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetFirstEdge", 1, 1, 1, i); __PYX_ERR(0, 73, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_CopyGraph", 1, 1, 1, i); __PYX_ERR(0, 65, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 73, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 65, __pyx_L3_error) } - __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L3_error) + __pyx_v_src_graph = ((struct __pyx_obj_9planarity_4full_5graph_Graph *)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_GetFirstEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 73, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_CopyGraph", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 65, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetFirstEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_src_graph), __pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, 1, "src_graph", 0))) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_14gp_CopyGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_src_graph); /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + goto __pyx_L7_cleaned_up; + __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } + __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_14gp_CopyGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph) { + PyObject *__pyx_v_src_graph_uninit_error = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + char const *__pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + PyObject *__pyx_t_19 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetFirstEdge", 0); + __Pyx_RefNannySetupContext("gp_CopyGraph", 0); - /* "planarity/full/graph.pyx":74 - * - * def gp_GetFirstEdge(self, int v): - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":68 + * # NOTE: this is interpreting the self as the dstGraph, i.e. copying + * # the Graph wrapper that is passed in as the srcGraph + * if self._theGraph == NULL: # <<<<<<<<<<<<<< * raise RuntimeError( - * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." + * "Invalid destination graph: wrapped graphP is NULL." */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { + __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":75 - * def gp_GetFirstEdge(self, int v): - * if not self.gp_IsVertex(v): + /* "planarity/full/graph.pyx":69 + * # the Graph wrapper that is passed in as the srcGraph + * if self._theGraph == NULL: * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." + * "Invalid destination graph: wrapped graphP is NULL." * ) */ __pyx_t_3 = NULL; - - /* "planarity/full/graph.pyx":76 - * if not self.gp_IsVertex(v): - * raise RuntimeError( - * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." # <<<<<<<<<<<<<< - * ) - * -*/ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetFirstEdge_failed_invalid_v; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 48 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Invalid_destination_graph_wrappe}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 69, __pyx_L1_error) - /* "planarity/full/graph.pyx":74 - * - * def gp_GetFirstEdge(self, int v): - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":68 + * # NOTE: this is interpreting the self as the dstGraph, i.e. copying + * # the Graph wrapper that is passed in as the srcGraph + * if self._theGraph == NULL: # <<<<<<<<<<<<<< * raise RuntimeError( - * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." + * "Invalid destination graph: wrapped graphP is NULL." */ } - /* "planarity/full/graph.pyx":79 + /* "planarity/full/graph.pyx":73 * ) * - * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) # <<<<<<<<<<<<<< - * - * def gp_GetNextEdge(self, int e): + * try: # <<<<<<<<<<<<<< + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetFirstEdge(__pyx_v_self->_theGraph, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + /*try:*/ { - /* "planarity/full/graph.pyx":73 - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) + /* "planarity/full/graph.pyx":74 * - * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError( + * try: + * if src_graph.gp_GetN() == 0: # <<<<<<<<<<<<<< + * raise ValueError("Source graph has not been initialized.") + * except RuntimeError as src_graph_uninit_error: */ + __pyx_t_3 = ((PyObject *)__pyx_v_src_graph); + __Pyx_INCREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 74, __pyx_L4_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(__pyx_t_1)) { - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetFirstEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "planarity/full/graph.pyx":75 + * try: + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") # <<<<<<<<<<<<<< + * except RuntimeError as src_graph_uninit_error: + * raise ValueError( +*/ + __pyx_t_3 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Source_graph_has_not_been_initia}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 75, __pyx_L4_error) -/* "planarity/full/graph.pyx":81 - * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + /* "planarity/full/graph.pyx":74 * - * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * try: + * if src_graph.gp_GetN() == 0: # <<<<<<<<<<<<<< + * raise ValueError("Source graph has not been initialized.") + * except RuntimeError as src_graph_uninit_error: */ - -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_17gp_GetNextEdge(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_16gp_GetNextEdge, "Graph.gp_GetNextEdge(self, int e)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_17gp_GetNextEdge = {"gp_GetNextEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_17gp_GetNextEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_16gp_GetNextEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_17gp_GetNextEdge(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - int __pyx_v_e; - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetNextEdge (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; - const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 81, __pyx_L3_error) - if (__pyx_kwds_len > 0) { - switch (__pyx_nargs) { - case 1: - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 81, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; } - const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetNextEdge", 0) < (0)) __PYX_ERR(0, 81, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetNextEdge", 1, 1, 1, i); __PYX_ERR(0, 81, __pyx_L3_error) } - } - } else if (unlikely(__pyx_nargs != 1)) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 81, __pyx_L3_error) + + /* "planarity/full/graph.pyx":73 + * ) + * + * try: # <<<<<<<<<<<<<< + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") +*/ } - __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L3_error) - } - goto __pyx_L6_skip; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_GetNextEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 81, __pyx_L3_error) - __pyx_L6_skip:; - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNextEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_16gp_GetNextEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L9_try_end; + __pyx_L4_error:; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - /* function exit code */ - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "planarity/full/graph.pyx":76 + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") + * except RuntimeError as src_graph_uninit_error: # <<<<<<<<<<<<<< + * raise ValueError( + * "Invalid source graph: wrapped graphP is NULL." +*/ + __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_RuntimeError)))); + if (__pyx_t_8) { + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 76, __pyx_L6_except_error) + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_src_graph_uninit_error = __pyx_t_3; + /*try:*/ { -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_16gp_GetNextEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetNextEdge", 0); + /* "planarity/full/graph.pyx":77 + * raise ValueError("Source graph has not been initialized.") + * except RuntimeError as src_graph_uninit_error: + * raise ValueError( # <<<<<<<<<<<<<< + * "Invalid source graph: wrapped graphP is NULL." + * ) from src_graph_uninit_error +*/ + __pyx_t_11 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Invalid_source_graph_wrapped_gra}; + __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 77, __pyx_L16_error) + __Pyx_GOTREF(__pyx_t_10); + } - /* "planarity/full/graph.pyx":82 + /* "planarity/full/graph.pyx":79 + * raise ValueError( + * "Invalid source graph: wrapped graphP is NULL." + * ) from src_graph_uninit_error # <<<<<<<<<<<<<< * - * def gp_GetNextEdge(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_GetNextEdge() failed: invalid edge index '{e}'." + * if self.gp_GetN() != src_graph.gp_GetN(): */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_src_graph_uninit_error); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __PYX_ERR(0, 77, __pyx_L16_error) + } + + /* "planarity/full/graph.pyx":76 + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") + * except RuntimeError as src_graph_uninit_error: # <<<<<<<<<<<<<< + * raise ValueError( + * "Invalid source graph: wrapped graphP is NULL." +*/ + /*finally:*/ { + __pyx_L16_error:; + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; + __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); + if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __Pyx_XGOTREF(__pyx_t_19); + __pyx_t_8 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; + { + __Pyx_DECREF(__pyx_v_src_graph_uninit_error); __pyx_v_src_graph_uninit_error = 0; + } + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_XGIVEREF(__pyx_t_19); + __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; + __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; + goto __pyx_L6_except_error; + } + } + } + goto __pyx_L6_except_error; + + /* "planarity/full/graph.pyx":73 + * ) + * + * try: # <<<<<<<<<<<<<< + * if src_graph.gp_GetN() == 0: + * raise ValueError("Source graph has not been initialized.") +*/ + __pyx_L6_except_error:; + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + goto __pyx_L1_error; + __pyx_L9_try_end:; + } + + /* "planarity/full/graph.pyx":81 + * ) from src_graph_uninit_error + * + * if self.gp_GetN() != src_graph.gp_GetN(): # <<<<<<<<<<<<<< + * raise ValueError( + * "Source and destination graphs must have the same order " +*/ + __pyx_t_3 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + } + __pyx_t_2 = ((PyObject *)__pyx_v_src_graph); __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; + __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { - - /* "planarity/full/graph.pyx":83 - * def gp_GetNextEdge(self, int e): - * if not self.gp_IsEdge(e): - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_GetNextEdge() failed: invalid edge index '{e}'." - * ) -*/ - __pyx_t_3 = NULL; + __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 81, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":84 - * if not self.gp_IsEdge(e): - * raise RuntimeError( - * f"gp_GetNextEdge() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< - * ) + /* "planarity/full/graph.pyx":82 * + * if self.gp_GetN() != src_graph.gp_GetN(): + * raise ValueError( # <<<<<<<<<<<<<< + * "Source and destination graphs must have the same order " + * "to copy graphP struct.") */ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetNextEdge_failed_invalid_ed; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 45 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = NULL; __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Source_and_destination_graphs_mu}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 83, __pyx_L1_error) + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 82, __pyx_L1_error) - /* "planarity/full/graph.pyx":82 + /* "planarity/full/graph.pyx":81 + * ) from src_graph_uninit_error * - * def gp_GetNextEdge(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_GetNextEdge() failed: invalid edge index '{e}'." + * if self.gp_GetN() != src_graph.gp_GetN(): # <<<<<<<<<<<<<< + * raise ValueError( + * "Source and destination graphs must have the same order " */ } - /* "planarity/full/graph.pyx":87 - * ) + /* "planarity/full/graph.pyx":86 + * "to copy graphP struct.") * - * return cgraphLib.gp_GetNextEdge(self._theGraph, e) # <<<<<<<<<<<<<< + * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_CopyGraph() failed.") * - * def gp_GetNeighbor(self, int e): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetNextEdge(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_2 = __Pyx_PyLong_From_int(gp_CopyGraph(__pyx_v_self->_theGraph, __pyx_v_src_graph->_theGraph)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":81 - * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + /* "planarity/full/graph.pyx":87 * - * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: + * raise RuntimeError(f"gp_CopyGraph() failed.") # <<<<<<<<<<<<<< + * + * def gp_DupGraph(self) -> Graph: */ + __pyx_t_3 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_CopyGraph_failed}; + __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_Raise(__pyx_t_9, 0, 0, 0); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __PYX_ERR(0, 87, __pyx_L1_error) - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNextEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; + /* "planarity/full/graph.pyx":86 + * "to copy graphP struct.") + * + * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_CopyGraph() failed.") + * +*/ + } + + /* "planarity/full/graph.pyx":65 + * return cgraphLib.gp_GetN(self._theGraph) + * + * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< + * # NOTE: this is interpreting the self as the dstGraph, i.e. copying + * # the Graph wrapper that is passed in as the srcGraph +*/ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_src_graph_uninit_error); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "planarity/full/graph.pyx":89 - * return cgraphLib.gp_GetNextEdge(self._theGraph, e) + * raise RuntimeError(f"gp_CopyGraph() failed.") * - * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_19gp_GetNeighbor(PyObject *__pyx_v_self, +static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pw_9planarity_4full_5graph_5Graph_17gp_DupGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_18gp_GetNeighbor, "Graph.gp_GetNeighbor(self, int e)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_19gp_GetNeighbor = {"gp_GetNeighbor", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_19gp_GetNeighbor, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_18gp_GetNeighbor}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_19gp_GetNeighbor(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_16gp_DupGraph, "Graph.gp_DupGraph(self) -> Graph"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_17gp_DupGraph = {"gp_DupGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_17gp_DupGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_16gp_DupGraph}; +static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pw_9planarity_4full_5graph_5Graph_17gp_DupGraph(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_e; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; + struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetNeighbor (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_DupGraph (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -4399,216 +4267,187 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; - const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 89, __pyx_L3_error) - if (__pyx_kwds_len > 0) { - switch (__pyx_nargs) { - case 1: - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 89, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetNeighbor", 0) < (0)) __PYX_ERR(0, 89, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetNeighbor", 1, 1, 1, i); __PYX_ERR(0, 89, __pyx_L3_error) } - } - } else if (unlikely(__pyx_nargs != 1)) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 89, __pyx_L3_error) - } - __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L3_error) - } - goto __pyx_L6_skip; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_GetNeighbor", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 89, __pyx_L3_error) - __pyx_L6_skip:; - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNeighbor", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_18gp_GetNeighbor(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_DupGraph", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_DupGraph", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_16gp_DupGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_18gp_GetNeighbor(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { - PyObject *__pyx_r = NULL; +static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pf_9planarity_4full_5graph_5Graph_16gp_DupGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + graphP __pyx_v_theGraph_dup; + struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_new_graph = 0; + struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetNeighbor", 0); + __Pyx_RefNannySetupContext("gp_DupGraph", 0); /* "planarity/full/graph.pyx":90 * - * def gp_GetNeighbor(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_GetNeighbor() failed: invalid edge index '{e}'." + * def gp_DupGraph(self) -> Graph: + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) # <<<<<<<<<<<<<< + * if theGraph_dup == NULL: + * raise MemoryError("gp_DupGraph() failed.") */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { + __pyx_v_theGraph_dup = gp_DupGraph(__pyx_v_self->_theGraph); - /* "planarity/full/graph.pyx":91 - * def gp_GetNeighbor(self, int e): - * if not self.gp_IsEdge(e): - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_GetNeighbor() failed: invalid edge index '{e}'." - * ) + /* "planarity/full/graph.pyx":91 + * def gp_DupGraph(self) -> Graph: + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: # <<<<<<<<<<<<<< + * raise MemoryError("gp_DupGraph() failed.") + * */ - __pyx_t_3 = NULL; + __pyx_t_1 = (__pyx_v_theGraph_dup == NULL); + if (unlikely(__pyx_t_1)) { /* "planarity/full/graph.pyx":92 - * if not self.gp_IsEdge(e): - * raise RuntimeError( - * f"gp_GetNeighbor() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< - * ) + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: + * raise MemoryError("gp_DupGraph() failed.") # <<<<<<<<<<<<<< * + * cdef Graph new_graph = Graph() */ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetNeighbor_failed_invalid_ed; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 45 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = NULL; __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_DupGraph_failed}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_MemoryError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 92, __pyx_L1_error) - /* "planarity/full/graph.pyx":90 + /* "planarity/full/graph.pyx":91 + * def gp_DupGraph(self) -> Graph: + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: # <<<<<<<<<<<<<< + * raise MemoryError("gp_DupGraph() failed.") * - * def gp_GetNeighbor(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_GetNeighbor() failed: invalid edge index '{e}'." */ } + /* "planarity/full/graph.pyx":94 + * raise MemoryError("gp_DupGraph() failed.") + * + * cdef Graph new_graph = Graph() # <<<<<<<<<<<<<< + * cgraphLib.gp_Free(&new_graph._theGraph) + * new_graph._theGraph = theGraph_dup +*/ + __pyx_t_3 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) + __Pyx_GOTREF((PyObject *)__pyx_t_2); + } + __pyx_v_new_graph = ((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_t_2); + __pyx_t_2 = 0; + /* "planarity/full/graph.pyx":95 - * ) * - * return cgraphLib.gp_GetNeighbor(self._theGraph, e) # <<<<<<<<<<<<<< + * cdef Graph new_graph = Graph() + * cgraphLib.gp_Free(&new_graph._theGraph) # <<<<<<<<<<<<<< + * new_graph._theGraph = theGraph_dup * - * def gp_IsVertex(self, int v): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetNeighbor(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + gp_Free((&__pyx_v_new_graph->_theGraph)); + + /* "planarity/full/graph.pyx":96 + * cdef Graph new_graph = Graph() + * cgraphLib.gp_Free(&new_graph._theGraph) + * new_graph._theGraph = theGraph_dup # <<<<<<<<<<<<<< + * + * return new_graph +*/ + __pyx_v_new_graph->_theGraph = __pyx_v_theGraph_dup; + + /* "planarity/full/graph.pyx":98 + * new_graph._theGraph = theGraph_dup + * + * return new_graph # <<<<<<<<<<<<<< + * + * def gp_FindEdge(self, int u, int v): +*/ + __Pyx_XDECREF((PyObject *)__pyx_r); + __Pyx_INCREF((PyObject *)__pyx_v_new_graph); + __pyx_r = __pyx_v_new_graph; goto __pyx_L0; /* "planarity/full/graph.pyx":89 - * return cgraphLib.gp_GetNextEdge(self._theGraph, e) + * raise RuntimeError(f"gp_CopyGraph() failed.") * - * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNeighbor", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DupGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); + __Pyx_XDECREF((PyObject *)__pyx_v_new_graph); + __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":97 - * return cgraphLib.gp_GetNeighbor(self._theGraph, e) +/* "planarity/full/graph.pyx":100 + * return new_graph * - * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< - * return ( - * (v >= self.gp_GetFirstVertex()) and + * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_21gp_IsVertex(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_19gp_FindEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_20gp_IsVertex, "Graph.gp_IsVertex(self, int v)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_21gp_IsVertex = {"gp_IsVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_21gp_IsVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_20gp_IsVertex}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_21gp_IsVertex(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_18gp_FindEdge, "Graph.gp_FindEdge(self, int u, int v)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_19gp_FindEdge = {"gp_FindEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_19gp_FindEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_18gp_FindEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_19gp_FindEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { + int __pyx_v_u; int __pyx_v_v; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; + PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_IsVertex (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_FindEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -4618,45 +4457,52 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_u,&__pyx_mstate_global->__pyx_n_u_v,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 97, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 100, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { + case 2: + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 100, __pyx_L3_error) + CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 97, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 100, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_IsVertex", 0) < (0)) __PYX_ERR(0, 97, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_IsVertex", 1, 1, 1, i); __PYX_ERR(0, 97, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_FindEdge", 0) < (0)) __PYX_ERR(0, 100, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_FindEdge", 1, 2, 2, i); __PYX_ERR(0, 100, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 1)) { + } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 97, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 100, __pyx_L3_error) + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 100, __pyx_L3_error) } - __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L3_error) + __pyx_v_u = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_u == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L3_error) + __pyx_v_v = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_IsVertex", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 97, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_FindEdge", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 100, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_FindEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_20gp_IsVertex(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_18gp_FindEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_u, __pyx_v_v); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -4666,117 +4512,170 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_IsVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_18gp_FindEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_v) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - size_t __pyx_t_5; + size_t __pyx_t_4; + int __pyx_t_5; int __pyx_t_6; - int __pyx_t_7; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_IsVertex", 0); + __Pyx_RefNannySetupContext("gp_FindEdge", 0); - /* "planarity/full/graph.pyx":98 + /* "planarity/full/graph.pyx":101 * - * def gp_IsVertex(self, int v): - * return ( # <<<<<<<<<<<<<< - * (v >= self.gp_GetFirstVertex()) and - * (v <= self.gp_GetLastVertex()) and -*/ - __Pyx_XDECREF(__pyx_r); - - /* "planarity/full/graph.pyx":99 - * def gp_IsVertex(self, int v): - * return ( - * (v >= self.gp_GetFirstVertex()) and # <<<<<<<<<<<<<< - * (v <= self.gp_GetLastVertex()) and - * cgraphLib.gp_IsVertex(self._theGraph, v) + * def gp_FindEdge(self, int u, int v): + * if not self.gp_IsVertex(u): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * if not self.gp_IsVertex(v): */ - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_5 = 0; + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_u); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetFirstVertex, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 99, __pyx_L1_error) - if (__pyx_t_6) { - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __Pyx_INCREF(__pyx_t_4); - __pyx_t_1 = __pyx_t_4; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L3_bool_binop_done; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 101, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { + + /* "planarity/full/graph.pyx":102 + * def gp_FindEdge(self, int u, int v): + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") +*/ + __pyx_t_3 = NULL; + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_u, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 30, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 102, __pyx_L1_error) + + /* "planarity/full/graph.pyx":101 + * + * def gp_FindEdge(self, int u, int v): + * if not self.gp_IsVertex(u): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * if not self.gp_IsVertex(v): +*/ } - /* "planarity/full/graph.pyx":100 - * return ( - * (v >= self.gp_GetFirstVertex()) and - * (v <= self.gp_GetLastVertex()) and # <<<<<<<<<<<<<< - * cgraphLib.gp_IsVertex(self._theGraph, v) - * ) + /* "planarity/full/graph.pyx":103 + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * */ - __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_5 = 0; + __pyx_t_8 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_8); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetLastVertex, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 100, __pyx_L1_error) - if (__pyx_t_6) { - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = __pyx_t_2; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L3_bool_binop_done; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 103, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (!__pyx_t_6); + if (unlikely(__pyx_t_5)) { + + /* "planarity/full/graph.pyx":104 + * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") # <<<<<<<<<<<<<< + * + * return cgraphLib.gp_FindEdge(self._theGraph, u, v) +*/ + __pyx_t_3 = NULL; + __pyx_t_8 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; + __pyx_t_7[1] = __pyx_t_8; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; + __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8) + 30, 127); + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_2}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 104, __pyx_L1_error) + + /* "planarity/full/graph.pyx":103 + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * +*/ } - /* "planarity/full/graph.pyx":101 - * (v >= self.gp_GetFirstVertex()) and - * (v <= self.gp_GetLastVertex()) and - * cgraphLib.gp_IsVertex(self._theGraph, v) # <<<<<<<<<<<<<< - * ) + /* "planarity/full/graph.pyx":106 + * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * + * return cgraphLib.gp_FindEdge(self._theGraph, u, v) # <<<<<<<<<<<<<< * + * def gp_GetVertexDegree(self, int v): */ - __pyx_t_7 = gp_IsVertex(__pyx_v_self->_theGraph, __pyx_v_v); - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __pyx_t_2; - __pyx_t_2 = 0; - __pyx_L3_bool_binop_done:; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_FindEdge(__pyx_v_self->_theGraph, __pyx_v_u, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":97 - * return cgraphLib.gp_GetNeighbor(self._theGraph, e) + /* "planarity/full/graph.pyx":100 + * return new_graph * - * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< - * return ( - * (v >= self.gp_GetFirstVertex()) and + * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") */ /* function exit code */ @@ -4784,8 +4683,8 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_IsVertex(struct __ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_FindEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -4793,38 +4692,43 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_IsVertex(struct __ return __pyx_r; } -/* "planarity/full/graph.pyx":104 - * ) - * - * def gp_GetFirstVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetFirstVertex(self._theGraph) +/* "planarity/full/graph.pyx":108 + * return cgraphLib.gp_FindEdge(self._theGraph, u, v) * + * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex, "Graph.gp_GetFirstVertex(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex = {"gp_GetFirstVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree, "Graph.gp_GetVertexDegree(self, int v)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree = {"gp_GetVertexDegree", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { + int __pyx_v_v; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetFirstVertex (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetVertexDegree (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -4833,145 +4737,164 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetFirstVertex", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetFirstVertex", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 108, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 108, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetVertexDegree", 0) < (0)) __PYX_ERR(0, 108, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetVertexDegree", 1, 1, 1, i); __PYX_ERR(0, 108, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 108, __pyx_L3_error) + } + __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L3_error) + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gp_GetVertexDegree", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 108, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetVertexDegree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetFirstVertex", 0); + __Pyx_RefNannySetupContext("gp_GetVertexDegree", 0); - /* "planarity/full/graph.pyx":105 + /* "planarity/full/graph.pyx":109 * - * def gp_GetFirstVertex(self): - * return cgraphLib.gp_GetFirstVertex(self._theGraph) # <<<<<<<<<<<<<< + * def gp_GetVertexDegree(self, int v): + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{v}' is not a valid vertex label.") * - * def gp_GetLastVertex(self): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetFirstVertex(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":104 - * ) - * - * def gp_GetFirstVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetFirstVertex(self._theGraph) + /* "planarity/full/graph.pyx":110 + * def gp_GetVertexDegree(self, int v): + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") # <<<<<<<<<<<<<< * + * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) */ + __pyx_t_3 = NULL; + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 30, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 110, __pyx_L1_error) - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetFirstVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":107 - * return cgraphLib.gp_GetFirstVertex(self._theGraph) + /* "planarity/full/graph.pyx":109 * - * def gp_GetLastVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetLastVertex(self._theGraph) + * def gp_GetVertexDegree(self, int v): + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError(f"'{v}' is not a valid vertex label.") * */ + } -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_25gp_GetLastVertex(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_24gp_GetLastVertex, "Graph.gp_GetLastVertex(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_25gp_GetLastVertex = {"gp_GetLastVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_25gp_GetLastVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_24gp_GetLastVertex}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_25gp_GetLastVertex(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetLastVertex (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetLastVertex", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetLastVertex", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_24gp_GetLastVertex(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_24gp_GetLastVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetLastVertex", 0); - - /* "planarity/full/graph.pyx":108 + /* "planarity/full/graph.pyx":112 + * raise RuntimeError(f"'{v}' is not a valid vertex label.") * - * def gp_GetLastVertex(self): - * return cgraphLib.gp_GetLastVertex(self._theGraph) # <<<<<<<<<<<<<< + * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) # <<<<<<<<<<<<<< * - * def gp_VertexInRangeAscending(self, int v): + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetLastVertex(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetVertexDegree(__pyx_v_self->_theGraph, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":107 - * return cgraphLib.gp_GetFirstVertex(self._theGraph) - * - * def gp_GetLastVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetLastVertex(self._theGraph) + /* "planarity/full/graph.pyx":108 + * return cgraphLib.gp_FindEdge(self._theGraph, u, v) * + * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetLastVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetVertexDegree", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -4979,43 +4902,46 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_24gp_GetLastVertex(stru return __pyx_r; } -/* "planarity/full/graph.pyx":110 - * return cgraphLib.gp_GetLastVertex(self._theGraph) +/* "planarity/full/graph.pyx":114 + * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) * - * def gp_VertexInRangeAscending(self, int v): # <<<<<<<<<<<<<< - * return ( - * v >= self.gp_GetFirstVertex() and + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< + * if ulink != 0 and ulink != 1: + * raise RuntimeError( */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_23gp_AddEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending, "Graph.gp_VertexInRangeAscending(self, int v)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending = {"gp_VertexInRangeAscending", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_22gp_AddEdge, "Graph.gp_AddEdge(self, int u, int ulink, int v, int vlink)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_23gp_AddEdge = {"gp_AddEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_23gp_AddEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_22gp_AddEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_23gp_AddEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { + int __pyx_v_u; + int __pyx_v_ulink; int __pyx_v_v; + int __pyx_v_vlink; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; + PyObject* values[4] = {0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_VertexInRangeAscending (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_AddEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -5025,45 +4951,66 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_u,&__pyx_mstate_global->__pyx_n_u_ulink,&__pyx_mstate_global->__pyx_n_u_v,&__pyx_mstate_global->__pyx_n_u_vlink,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 110, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 114, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { + case 4: + values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 114, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 3: + values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 114, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 2: + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 114, __pyx_L3_error) + CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 110, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 114, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_VertexInRangeAscending", 0) < (0)) __PYX_ERR(0, 110, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_VertexInRangeAscending", 1, 1, 1, i); __PYX_ERR(0, 110, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_AddEdge", 0) < (0)) __PYX_ERR(0, 114, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 4; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_AddEdge", 1, 4, 4, i); __PYX_ERR(0, 114, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 1)) { + } else if (unlikely(__pyx_nargs != 4)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 110, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 114, __pyx_L3_error) + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 114, __pyx_L3_error) + values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 114, __pyx_L3_error) + values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 114, __pyx_L3_error) } - __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L3_error) + __pyx_v_u = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_u == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L3_error) + __pyx_v_ulink = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_ulink == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L3_error) + __pyx_v_v = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L3_error) + __pyx_v_vlink = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_vlink == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_VertexInRangeAscending", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 110, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_AddEdge", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 114, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_VertexInRangeAscending", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_AddEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_22gp_AddEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_u, __pyx_v_ulink, __pyx_v_v, __pyx_v_vlink); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -5073,231 +5020,271 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_22gp_AddEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_ulink, int __pyx_v_v, int __pyx_v_vlink) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - size_t __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; + PyObject *__pyx_t_5[3]; + PyObject *__pyx_t_6 = NULL; + size_t __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10[9]; + PyObject *__pyx_t_11 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_VertexInRangeAscending", 0); + __Pyx_RefNannySetupContext("gp_AddEdge", 0); - /* "planarity/full/graph.pyx":111 + /* "planarity/full/graph.pyx":115 * - * def gp_VertexInRangeAscending(self, int v): - * return ( # <<<<<<<<<<<<<< - * v >= self.gp_GetFirstVertex() and - * cgraphLib.gp_VertexInRangeAscending(self._theGraph, v) + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): + * if ulink != 0 and ulink != 1: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Invalid link index for ulink: '{ulink}'." */ - __Pyx_XDECREF(__pyx_r); + switch (__pyx_v_ulink) { + case 0: + case 1: + __pyx_t_1 = 0; + break; + default: + __pyx_t_1 = 1; + break; + } + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":112 - * def gp_VertexInRangeAscending(self, int v): - * return ( - * v >= self.gp_GetFirstVertex() and # <<<<<<<<<<<<<< - * cgraphLib.gp_VertexInRangeAscending(self._theGraph, v) - * ) + /* "planarity/full/graph.pyx":116 + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): + * if ulink != 0 and ulink != 1: + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"Invalid link index for ulink: '{ulink}'." + * ) */ - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_5 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetFirstVertex, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 112, __pyx_L1_error) - if (__pyx_t_6) { - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __Pyx_INCREF(__pyx_t_4); - __pyx_t_1 = __pyx_t_4; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L3_bool_binop_done; - } + __pyx_t_3 = NULL; - /* "planarity/full/graph.pyx":113 - * return ( - * v >= self.gp_GetFirstVertex() and - * cgraphLib.gp_VertexInRangeAscending(self._theGraph, v) # <<<<<<<<<<<<<< - * ) - * + /* "planarity/full/graph.pyx":117 + * if ulink != 0 and ulink != 1: + * raise RuntimeError( + * f"Invalid link index for ulink: '{ulink}'." # <<<<<<<<<<<<<< + * ) + * if vlink != 0 and vlink != 1: */ - __pyx_t_7 = gp_VertexInRangeAscending(__pyx_v_self->_theGraph, __pyx_v_v); - __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_L3_bool_binop_done:; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_ulink, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_link_index_for_ulink; + __pyx_t_5[1] = __pyx_t_4; + __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 31 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4) + 2, 127); + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_7 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_6}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 116, __pyx_L1_error) - /* "planarity/full/graph.pyx":110 - * return cgraphLib.gp_GetLastVertex(self._theGraph) + /* "planarity/full/graph.pyx":115 * - * def gp_VertexInRangeAscending(self, int v): # <<<<<<<<<<<<<< - * return ( - * v >= self.gp_GetFirstVertex() and + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): + * if ulink != 0 and ulink != 1: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Invalid link index for ulink: '{ulink}'." */ + } - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_VertexInRangeAscending", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":116 - * ) - * - * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< - * """ - * Returns the number of vertices in the graph. + /* "planarity/full/graph.pyx":119 + * f"Invalid link index for ulink: '{ulink}'." + * ) + * if vlink != 0 and vlink != 1: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Invalid link index for vlink: '{vlink}'." */ + switch (__pyx_v_vlink) { + case 0: + case 1: + __pyx_t_1 = 0; + break; + default: + __pyx_t_1 = 1; + break; + } + if (unlikely(__pyx_t_1)) { -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_29gp_GetN(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_28gp_GetN, "Graph.gp_GetN(self) -> int\n\nReturns the number of vertices in the graph."); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_29gp_GetN = {"gp_GetN", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_29gp_GetN, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_28gp_GetN}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_29gp_GetN(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetN (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetN", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetN", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_28gp_GetN(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_28gp_GetN(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetN", 0); - - /* "planarity/full/graph.pyx":120 - * Returns the number of vertices in the graph. - * """ - * if self._theGraph == NULL: # <<<<<<<<<<<<<< - * raise RuntimeError("Graph is not initialized.") - * + /* "planarity/full/graph.pyx":120 + * ) + * if vlink != 0 and vlink != 1: + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"Invalid link index for vlink: '{vlink}'." + * ) */ - __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); - if (unlikely(__pyx_t_1)) { + __pyx_t_6 = NULL; /* "planarity/full/graph.pyx":121 - * """ - * if self._theGraph == NULL: - * raise RuntimeError("Graph is not initialized.") # <<<<<<<<<<<<<< - * - * return cgraphLib.gp_GetN(self._theGraph) + * if vlink != 0 and vlink != 1: + * raise RuntimeError( + * f"Invalid link index for vlink: '{vlink}'." # <<<<<<<<<<<<<< + * ) + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: */ - __pyx_t_3 = NULL; - __pyx_t_4 = 1; + __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_vlink, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_link_index_for_vlink; + __pyx_t_5[1] = __pyx_t_3; + __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 31 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 2, 127); + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_7 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Graph_is_not_initialized}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 121, __pyx_L1_error) + __PYX_ERR(0, 120, __pyx_L1_error) - /* "planarity/full/graph.pyx":120 - * Returns the number of vertices in the graph. - * """ - * if self._theGraph == NULL: # <<<<<<<<<<<<<< - * raise RuntimeError("Graph is not initialized.") - * + /* "planarity/full/graph.pyx":119 + * f"Invalid link index for ulink: '{ulink}'." + * ) + * if vlink != 0 and vlink != 1: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Invalid link index for vlink: '{vlink}'." */ } /* "planarity/full/graph.pyx":123 - * raise RuntimeError("Graph is not initialized.") - * - * return cgraphLib.gp_GetN(self._theGraph) # <<<<<<<<<<<<<< - * - * def gp_InitGraph(self, int n): + * f"Invalid link index for vlink: '{vlink}'." + * ) + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyLong_From_int(gp_GetN(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(gp_AddEdge(__pyx_v_self->_theGraph, __pyx_v_u, __pyx_v_ulink, __pyx_v_v, __pyx_v_vlink)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 123, __pyx_L1_error) - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":116 - * ) + /* "planarity/full/graph.pyx":124 + * ) + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " + * f"and vlink = {vlink}." +*/ + __pyx_t_4 = NULL; + + /* "planarity/full/graph.pyx":125 + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: + * raise RuntimeError( + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " # <<<<<<<<<<<<<< + * f"and vlink = {vlink}." + * ) +*/ + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_u, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = __Pyx_PyUnicode_From_int(__pyx_v_ulink, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + + /* "planarity/full/graph.pyx":126 + * raise RuntimeError( + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " + * f"and vlink = {vlink}." # <<<<<<<<<<<<<< + * ) * - * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< - * """ - * Returns the number of vertices in the graph. +*/ + __pyx_t_9 = __Pyx_PyUnicode_From_int(__pyx_v_vlink, 0, ' ', 'd'); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10[0] = __pyx_mstate_global->__pyx_kp_u_Unable_to_add_edge_u_v; + __pyx_t_10[1] = __pyx_t_2; + __pyx_t_10[2] = __pyx_mstate_global->__pyx_kp_u__4; + __pyx_t_10[3] = __pyx_t_3; + __pyx_t_10[4] = __pyx_mstate_global->__pyx_kp_u_with_ulink; + __pyx_t_10[5] = __pyx_t_8; + __pyx_t_10[6] = __pyx_mstate_global->__pyx_kp_u_and_vlink; + __pyx_t_10[7] = __pyx_t_9; + __pyx_t_10[8] = __pyx_mstate_global->__pyx_kp_u_; + + /* "planarity/full/graph.pyx":125 + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: + * raise RuntimeError( + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " # <<<<<<<<<<<<<< + * f"and vlink = {vlink}." + * ) +*/ + __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_10, 9, 29 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 15 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8) + 13 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9) + 1, 127); + if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_7 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_11}; + __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(0, 124, __pyx_L1_error) + + /* "planarity/full/graph.pyx":123 + * f"Invalid link index for vlink: '{vlink}'." + * ) + * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " +*/ + } + + /* "planarity/full/graph.pyx":114 + * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) + * + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< + * if ulink != 0 and ulink != 1: + * raise RuntimeError( */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetN", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_AddEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5305,32 +5292,32 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_28gp_GetN(struct __pyx_ return __pyx_r; } -/* "planarity/full/graph.pyx":125 - * return cgraphLib.gp_GetN(self._theGraph) +/* "planarity/full/graph.pyx":129 + * ) * - * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: - * raise RuntimeError(f"gp_InitGraph() failed.") + * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_31gp_InitGraph(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_25gp_DeleteEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_30gp_InitGraph, "Graph.gp_InitGraph(self, int n)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_31gp_InitGraph = {"gp_InitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_31gp_InitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_30gp_InitGraph}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_31gp_InitGraph(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_24gp_DeleteEdge, "Graph.gp_DeleteEdge(self, int e)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_25gp_DeleteEdge = {"gp_DeleteEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_25gp_DeleteEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_24gp_DeleteEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_25gp_DeleteEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_n; + int __pyx_v_e; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -5341,7 +5328,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_InitGraph (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_DeleteEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -5351,45 +5338,45 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 125, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 129, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 125, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 129, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_InitGraph", 0) < (0)) __PYX_ERR(0, 125, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_DeleteEdge", 0) < (0)) __PYX_ERR(0, 129, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_InitGraph", 1, 1, 1, i); __PYX_ERR(0, 125, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_DeleteEdge", 1, 1, 1, i); __PYX_ERR(0, 129, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 125, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 129, __pyx_L3_error) } - __pyx_v_n = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L3_error) + __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 129, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_InitGraph", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 125, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_DeleteEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 129, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_InitGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DeleteEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_30gp_InitGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_n); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_24gp_DeleteEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -5399,82 +5386,123 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_30gp_InitGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_n) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_24gp_DeleteEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - size_t __pyx_t_5; + size_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_InitGraph", 0); + __Pyx_RefNannySetupContext("gp_DeleteEdge", 0); - /* "planarity/full/graph.pyx":126 - * - * def gp_InitGraph(self, int n): - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_InitGraph() failed.") + /* "planarity/full/graph.pyx":130 * + * def gp_DeleteEdge(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_DeleteEdge() failed: invalid edge '{e}'." */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_InitGraph(__pyx_v_self->_theGraph, __pyx_v_n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__pyx_t_4)) { + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":127 - * def gp_InitGraph(self, int n): - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: - * raise RuntimeError(f"gp_InitGraph() failed.") # <<<<<<<<<<<<<< - * - * def gp_ReinitializeGraph(self): + /* "planarity/full/graph.pyx":131 + * def gp_DeleteEdge(self, int e): + * if not self.gp_IsEdge(e): + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_DeleteEdge() failed: invalid edge '{e}'." + * ) */ - __pyx_t_2 = NULL; - __pyx_t_5 = 1; + __pyx_t_3 = NULL; + + /* "planarity/full/graph.pyx":132 + * if not self.gp_IsEdge(e): + * raise RuntimeError( + * f"gp_DeleteEdge() failed: invalid edge '{e}'." # <<<<<<<<<<<<<< + * ) + * +*/ + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_DeleteEdge_failed_invalid_edg; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 38 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_gp_InitGraph_failed}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 131, __pyx_L1_error) - /* "planarity/full/graph.pyx":126 - * - * def gp_InitGraph(self, int n): - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_InitGraph() failed.") + /* "planarity/full/graph.pyx":130 * + * def gp_DeleteEdge(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_DeleteEdge() failed: invalid edge '{e}'." */ } - /* "planarity/full/graph.pyx":125 - * return cgraphLib.gp_GetN(self._theGraph) + /* "planarity/full/graph.pyx":135 + * ) * - * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: - * raise RuntimeError(f"gp_InitGraph() failed.") + * return cgraphLib.gp_DeleteEdge(self._theGraph, e) # <<<<<<<<<<<<<< + * + * def gp_LowerBoundEdgeStorage(self): +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_DeleteEdge(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "planarity/full/graph.pyx":129 + * ) + * + * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_InitGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DeleteEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5482,25 +5510,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_30gp_InitGraph(struct _ return __pyx_r; } -/* "planarity/full/graph.pyx":129 - * raise RuntimeError(f"gp_InitGraph() failed.") +/* "planarity/full/graph.pyx":137 + * return cgraphLib.gp_DeleteEdge(self._theGraph, e) * - * def gp_ReinitializeGraph(self): # <<<<<<<<<<<<<< - * cgraphLib.gp_ReinitializeGraph(self._theGraph) + * def gp_LowerBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) * */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph, "Graph.gp_ReinitializeGraph(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph = {"gp_ReinitializeGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage, "Graph.gp_LowerBoundEdgeStorage(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage = {"gp_LowerBoundEdgeStorage", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -5513,7 +5541,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ReinitializeGraph (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_LowerBoundEdgeStorage (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -5522,72 +5550,178 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ReinitializeGraph", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_LowerBoundEdgeStorage", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ReinitializeGraph", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_LowerBoundEdgeStorage", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ReinitializeGraph", 0); + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_LowerBoundEdgeStorage", 0); - /* "planarity/full/graph.pyx":130 + /* "planarity/full/graph.pyx":138 * - * def gp_ReinitializeGraph(self): - * cgraphLib.gp_ReinitializeGraph(self._theGraph) # <<<<<<<<<<<<<< + * def gp_LowerBoundEdgeStorage(self): + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) # <<<<<<<<<<<<<< * - * def gp_CopyGraph(self, Graph src_graph): + * def gp_UpperBoundEdgeStorage(self): */ - gp_ReinitializeGraph(__pyx_v_self->_theGraph); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_LowerBoundEdgeStorage(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":129 - * raise RuntimeError(f"gp_InitGraph() failed.") + /* "planarity/full/graph.pyx":137 + * return cgraphLib.gp_DeleteEdge(self._theGraph, e) * - * def gp_ReinitializeGraph(self): # <<<<<<<<<<<<<< - * cgraphLib.gp_ReinitializeGraph(self._theGraph) + * def gp_LowerBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) * */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_LowerBoundEdgeStorage", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":132 - * cgraphLib.gp_ReinitializeGraph(self._theGraph) +/* "planarity/full/graph.pyx":140 + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) + * + * def gp_UpperBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) * - * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< - * # NOTE: this is interpreting the self as the dstGraph, i.e. copying - * # the Graph wrapper that is passed in as the srcGraph */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_35gp_CopyGraph(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_34gp_CopyGraph, "Graph.gp_CopyGraph(self, Graph src_graph)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_35gp_CopyGraph = {"gp_CopyGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_35gp_CopyGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_34gp_CopyGraph}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_35gp_CopyGraph(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage, "Graph.gp_UpperBoundEdgeStorage(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage = {"gp_UpperBoundEdgeStorage", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph = 0; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_UpperBoundEdgeStorage (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_UpperBoundEdgeStorage", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_UpperBoundEdgeStorage", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_UpperBoundEdgeStorage", 0); + + /* "planarity/full/graph.pyx":141 + * + * def gp_UpperBoundEdgeStorage(self): + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) # <<<<<<<<<<<<<< + * + * def gp_IsEdge(self, int e): +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_UpperBoundEdgeStorage(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "planarity/full/graph.pyx":140 + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) + * + * def gp_UpperBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) + * +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_UpperBoundEdgeStorage", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "planarity/full/graph.pyx":143 + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) + * + * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< + * return ( + * (e >= self.gp_LowerBoundEdgeStorage()) and +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_31gp_IsEdge(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_30gp_IsEdge, "Graph.gp_IsEdge(self, int e)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_31gp_IsEdge = {"gp_IsEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_31gp_IsEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_30gp_IsEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_31gp_IsEdge(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + int __pyx_v_e; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -5598,7 +5732,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_CopyGraph (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_IsEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -5608,487 +5742,529 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_src_graph,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 132, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 143, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 132, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 143, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_CopyGraph", 0) < (0)) __PYX_ERR(0, 132, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_IsEdge", 0) < (0)) __PYX_ERR(0, 143, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_CopyGraph", 1, 1, 1, i); __PYX_ERR(0, 132, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_IsEdge", 1, 1, 1, i); __PYX_ERR(0, 143, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 132, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 143, __pyx_L3_error) } - __pyx_v_src_graph = ((struct __pyx_obj_9planarity_4full_5graph_Graph *)values[0]); + __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_CopyGraph", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 132, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_IsEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 143, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_src_graph), __pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, 1, "src_graph", 0))) __PYX_ERR(0, 132, __pyx_L1_error) - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_34gp_CopyGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_src_graph); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_30gp_IsEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - goto __pyx_L7_cleaned_up; - __pyx_L0:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_34gp_CopyGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_src_graph) { - PyObject *__pyx_v_src_graph_uninit_error = NULL; +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_30gp_IsEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; + PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - int __pyx_t_12; - char const *__pyx_t_13; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - PyObject *__pyx_t_17 = NULL; - PyObject *__pyx_t_18 = NULL; - PyObject *__pyx_t_19 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_CopyGraph", 0); - - /* "planarity/full/graph.pyx":135 - * # NOTE: this is interpreting the self as the dstGraph, i.e. copying - * # the Graph wrapper that is passed in as the srcGraph - * if self._theGraph == NULL: # <<<<<<<<<<<<<< - * raise RuntimeError( - * "Invalid destination graph: wrapped graphP is NULL." -*/ - __pyx_t_1 = (__pyx_v_self->_theGraph == NULL); - if (unlikely(__pyx_t_1)) { + __Pyx_RefNannySetupContext("gp_IsEdge", 0); - /* "planarity/full/graph.pyx":136 - * # the Graph wrapper that is passed in as the srcGraph - * if self._theGraph == NULL: - * raise RuntimeError( # <<<<<<<<<<<<<< - * "Invalid destination graph: wrapped graphP is NULL." - * ) + /* "planarity/full/graph.pyx":144 + * + * def gp_IsEdge(self, int e): + * return ( # <<<<<<<<<<<<<< + * (e >= self.gp_LowerBoundEdgeStorage()) and + * (e < self.gp_UpperBoundEdgeStorage()) and */ - __pyx_t_3 = NULL; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Invalid_destination_graph_wrappe}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); - /* "planarity/full/graph.pyx":135 - * # NOTE: this is interpreting the self as the dstGraph, i.e. copying - * # the Graph wrapper that is passed in as the srcGraph - * if self._theGraph == NULL: # <<<<<<<<<<<<<< - * raise RuntimeError( - * "Invalid destination graph: wrapped graphP is NULL." + /* "planarity/full/graph.pyx":145 + * def gp_IsEdge(self, int e): + * return ( + * (e >= self.gp_LowerBoundEdgeStorage()) and # <<<<<<<<<<<<<< + * (e < self.gp_UpperBoundEdgeStorage()) and + * cgraphLib.gp_IsEdge(self._theGraph, e) */ + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_4); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; + __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_LowerBoundEdgeStorage, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 145, __pyx_L1_error) + if (__pyx_t_6) { + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __Pyx_INCREF(__pyx_t_4); + __pyx_t_1 = __pyx_t_4; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L3_bool_binop_done; } - /* "planarity/full/graph.pyx":140 - * ) - * - * try: # <<<<<<<<<<<<<< - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") + /* "planarity/full/graph.pyx":146 + * return ( + * (e >= self.gp_LowerBoundEdgeStorage()) and + * (e < self.gp_UpperBoundEdgeStorage()) and # <<<<<<<<<<<<<< + * cgraphLib.gp_IsEdge(self._theGraph, e) + * ) */ + __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_5 = 0; { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); - __Pyx_XGOTREF(__pyx_t_5); - __Pyx_XGOTREF(__pyx_t_6); - __Pyx_XGOTREF(__pyx_t_7); - /*try:*/ { - - /* "planarity/full/graph.pyx":141 - * - * try: - * if src_graph.gp_GetN() == 0: # <<<<<<<<<<<<<< - * raise ValueError("Source graph has not been initialized.") - * except RuntimeError as src_graph_uninit_error: -*/ - __pyx_t_3 = ((PyObject *)__pyx_v_src_graph); - __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; - __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_2); - } - __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 141, __pyx_L4_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(__pyx_t_1)) { - - /* "planarity/full/graph.pyx":142 - * try: - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") # <<<<<<<<<<<<<< - * except RuntimeError as src_graph_uninit_error: - * raise ValueError( -*/ - __pyx_t_3 = NULL; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Source_graph_has_not_been_initia}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 142, __pyx_L4_error) + PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; + __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_UpperBoundEdgeStorage, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 146, __pyx_L1_error) + if (__pyx_t_6) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = __pyx_t_2; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L3_bool_binop_done; + } - /* "planarity/full/graph.pyx":141 + /* "planarity/full/graph.pyx":147 + * (e >= self.gp_LowerBoundEdgeStorage()) and + * (e < self.gp_UpperBoundEdgeStorage()) and + * cgraphLib.gp_IsEdge(self._theGraph, e) # <<<<<<<<<<<<<< + * ) * - * try: - * if src_graph.gp_GetN() == 0: # <<<<<<<<<<<<<< - * raise ValueError("Source graph has not been initialized.") - * except RuntimeError as src_graph_uninit_error: */ - } + __pyx_t_7 = gp_IsEdge(__pyx_v_self->_theGraph, __pyx_v_e); + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_L3_bool_binop_done:; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":140 - * ) + /* "planarity/full/graph.pyx":143 + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) * - * try: # <<<<<<<<<<<<<< - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") -*/ - } - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L9_try_end; - __pyx_L4_error:; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "planarity/full/graph.pyx":143 - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") - * except RuntimeError as src_graph_uninit_error: # <<<<<<<<<<<<<< - * raise ValueError( - * "Invalid source graph: wrapped graphP is NULL." + * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< + * return ( + * (e >= self.gp_LowerBoundEdgeStorage()) and */ - __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_RuntimeError)))); - if (__pyx_t_8) { - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 143, __pyx_L6_except_error) - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_9); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_src_graph_uninit_error = __pyx_t_3; - /*try:*/ { - /* "planarity/full/graph.pyx":144 - * raise ValueError("Source graph has not been initialized.") - * except RuntimeError as src_graph_uninit_error: - * raise ValueError( # <<<<<<<<<<<<<< - * "Invalid source graph: wrapped graphP is NULL." - * ) from src_graph_uninit_error -*/ - __pyx_t_11 = NULL; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Invalid_source_graph_wrapped_gra}; - __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 144, __pyx_L16_error) - __Pyx_GOTREF(__pyx_t_10); - } + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "planarity/full/graph.pyx":146 - * raise ValueError( - * "Invalid source graph: wrapped graphP is NULL." - * ) from src_graph_uninit_error # <<<<<<<<<<<<<< +/* "planarity/full/graph.pyx":150 + * ) * - * if self.gp_GetN() != src_graph.gp_GetN(): + * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ - __Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_src_graph_uninit_error); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __PYX_ERR(0, 144, __pyx_L16_error) - } - /* "planarity/full/graph.pyx":143 - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") - * except RuntimeError as src_graph_uninit_error: # <<<<<<<<<<<<<< - * raise ValueError( - * "Invalid source graph: wrapped graphP is NULL." -*/ - /*finally:*/ { - __pyx_L16_error:; - /*exception exit:*/{ - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); - if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); - __Pyx_XGOTREF(__pyx_t_14); - __Pyx_XGOTREF(__pyx_t_15); - __Pyx_XGOTREF(__pyx_t_16); - __Pyx_XGOTREF(__pyx_t_17); - __Pyx_XGOTREF(__pyx_t_18); - __Pyx_XGOTREF(__pyx_t_19); - __pyx_t_8 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; - { - __Pyx_DECREF(__pyx_v_src_graph_uninit_error); __pyx_v_src_graph_uninit_error = 0; - } - __Pyx_XGIVEREF(__pyx_t_17); - __Pyx_XGIVEREF(__pyx_t_18); - __Pyx_XGIVEREF(__pyx_t_19); - __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); - __Pyx_XGIVEREF(__pyx_t_14); - __Pyx_XGIVEREF(__pyx_t_15); - __Pyx_XGIVEREF(__pyx_t_16); - __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); - __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; - __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; - goto __pyx_L6_except_error; - } +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_33gp_EdgeInUse(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_32gp_EdgeInUse, "Graph.gp_EdgeInUse(self, int e)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_33gp_EdgeInUse = {"gp_EdgeInUse", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_33gp_EdgeInUse, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_32gp_EdgeInUse}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_33gp_EdgeInUse(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + int __pyx_v_e; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_EdgeInUse (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 150, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_EdgeInUse", 0) < (0)) __PYX_ERR(0, 150, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_EdgeInUse", 1, 1, 1, i); __PYX_ERR(0, 150, __pyx_L3_error) } } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error) } - goto __pyx_L6_except_error; + __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L3_error) + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gp_EdgeInUse", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 150, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeInUse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_32gp_EdgeInUse(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); - /* "planarity/full/graph.pyx":140 - * ) - * - * try: # <<<<<<<<<<<<<< - * if src_graph.gp_GetN() == 0: - * raise ValueError("Source graph has not been initialized.") -*/ - __pyx_L6_except_error:; - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_XGIVEREF(__pyx_t_6); - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); - goto __pyx_L1_error; - __pyx_L9_try_end:; + /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "planarity/full/graph.pyx":148 - * ) from src_graph_uninit_error +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_32gp_EdgeInUse(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_EdgeInUse", 0); + + /* "planarity/full/graph.pyx":151 * - * if self.gp_GetN() != src_graph.gp_GetN(): # <<<<<<<<<<<<<< - * raise ValueError( - * "Source and destination graphs must have the same order " + * def gp_EdgeInUse(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_EdgeInUse() failed: invalid edge index '{e}'." */ - __pyx_t_3 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; - __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - } - __pyx_t_2 = ((PyObject *)__pyx_v_src_graph); + __pyx_t_2 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; - __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(__pyx_t_1)) { + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":149 - * - * if self.gp_GetN() != src_graph.gp_GetN(): - * raise ValueError( # <<<<<<<<<<<<<< - * "Source and destination graphs must have the same order " - * "to copy graphP struct.") + /* "planarity/full/graph.pyx":152 + * def gp_EdgeInUse(self, int e): + * if not self.gp_IsEdge(e): + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_EdgeInUse() failed: invalid edge index '{e}'." + * ) */ __pyx_t_3 = NULL; + + /* "planarity/full/graph.pyx":153 + * if not self.gp_IsEdge(e): + * raise RuntimeError( + * f"gp_EdgeInUse() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< + * ) + * +*/ + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_EdgeInUse_failed_invalid_edge; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 43 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Source_and_destination_graphs_mu}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 149, __pyx_L1_error) + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 152, __pyx_L1_error) - /* "planarity/full/graph.pyx":148 - * ) from src_graph_uninit_error + /* "planarity/full/graph.pyx":151 * - * if self.gp_GetN() != src_graph.gp_GetN(): # <<<<<<<<<<<<<< - * raise ValueError( - * "Source and destination graphs must have the same order " + * def gp_EdgeInUse(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_EdgeInUse() failed: invalid edge index '{e}'." */ } - /* "planarity/full/graph.pyx":153 - * "to copy graphP struct.") + /* "planarity/full/graph.pyx":156 + * ) * - * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_CopyGraph() failed.") + * return cgraphLib.gp_EdgeInUse(self._theGraph, e) # <<<<<<<<<<<<<< * + * def gp_UpperBoundEdges(self): */ - __pyx_t_2 = __Pyx_PyLong_From_int(gp_CopyGraph(__pyx_v_self->_theGraph, __pyx_v_src_graph->_theGraph)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (unlikely(__pyx_t_1)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_EdgeInUse(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":154 + /* "planarity/full/graph.pyx":150 + * ) * - * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: - * raise RuntimeError(f"gp_CopyGraph() failed.") # <<<<<<<<<<<<<< + * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EdgeInUse", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "planarity/full/graph.pyx":158 + * return cgraphLib.gp_EdgeInUse(self._theGraph, e) + * + * def gp_UpperBoundEdges(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_DupGraph(self) -> Graph: */ - __pyx_t_3 = NULL; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_CopyGraph_failed}; - __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - } - __Pyx_Raise(__pyx_t_9, 0, 0, 0); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __PYX_ERR(0, 154, __pyx_L1_error) - /* "planarity/full/graph.pyx":153 - * "to copy graphP struct.") +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges, "Graph.gp_UpperBoundEdges(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges = {"gp_UpperBoundEdges", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_UpperBoundEdges (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_UpperBoundEdges", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_UpperBoundEdges", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_UpperBoundEdges", 0); + + /* "planarity/full/graph.pyx":159 * - * if cgraphLib.gp_CopyGraph(self._theGraph, src_graph._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_CopyGraph() failed.") + * def gp_UpperBoundEdges(self): + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) # <<<<<<<<<<<<<< * + * def gp_GetNextEdge(self, int e): */ - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_UpperBoundEdges(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":132 - * cgraphLib.gp_ReinitializeGraph(self._theGraph) + /* "planarity/full/graph.pyx":158 + * return cgraphLib.gp_EdgeInUse(self._theGraph, e) + * + * def gp_UpperBoundEdges(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< - * # NOTE: this is interpreting the self as the dstGraph, i.e. copying - * # the Graph wrapper that is passed in as the srcGraph */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_CopyGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_UpperBoundEdges", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_src_graph_uninit_error); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":156 - * raise RuntimeError(f"gp_CopyGraph() failed.") +/* "planarity/full/graph.pyx":161 + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: + * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* Python wrapper */ -static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pw_9planarity_4full_5graph_5Graph_37gp_DupGraph(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_37gp_GetNextEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_36gp_DupGraph, "Graph.gp_DupGraph(self) -> Graph"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_37gp_DupGraph = {"gp_DupGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_37gp_DupGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_36gp_DupGraph}; -static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pw_9planarity_4full_5graph_5Graph_37gp_DupGraph(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_36gp_GetNextEdge, "Graph.gp_GetNextEdge(self, int e)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_37gp_GetNextEdge = {"gp_GetNextEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_37gp_GetNextEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_36gp_GetNextEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_37gp_GetNextEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { + int __pyx_v_e; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_r = 0; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_DupGraph (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetNextEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -6097,175 +6273,205 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_DupGraph", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_DupGraph", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_36gp_DupGraph(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 161, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 161, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetNextEdge", 0) < (0)) __PYX_ERR(0, 161, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetNextEdge", 1, 1, 1, i); __PYX_ERR(0, 161, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 161, __pyx_L3_error) + } + __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L3_error) + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("gp_GetNextEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 161, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNextEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_36gp_GetNextEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } __Pyx_RefNannyFinishContext(); return __pyx_r; } -static struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_pf_9planarity_4full_5graph_5Graph_36gp_DupGraph(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - graphP __pyx_v_theGraph_dup; - struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_new_graph = 0; - struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_r = NULL; +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_36gp_GetNextEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; + PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_DupGraph", 0); + __Pyx_RefNannySetupContext("gp_GetNextEdge", 0); - /* "planarity/full/graph.pyx":157 + /* "planarity/full/graph.pyx":162 * - * def gp_DupGraph(self) -> Graph: - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) # <<<<<<<<<<<<<< - * if theGraph_dup == NULL: - * raise MemoryError("gp_DupGraph() failed.") + * def gp_GetNextEdge(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetNextEdge() failed: invalid edge index '{e}'." */ - __pyx_v_theGraph_dup = gp_DupGraph(__pyx_v_self->_theGraph); + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":158 - * def gp_DupGraph(self) -> Graph: - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: # <<<<<<<<<<<<<< - * raise MemoryError("gp_DupGraph() failed.") - * + /* "planarity/full/graph.pyx":163 + * def gp_GetNextEdge(self, int e): + * if not self.gp_IsEdge(e): + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_GetNextEdge() failed: invalid edge index '{e}'." + * ) */ - __pyx_t_1 = (__pyx_v_theGraph_dup == NULL); - if (unlikely(__pyx_t_1)) { + __pyx_t_3 = NULL; - /* "planarity/full/graph.pyx":159 - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: - * raise MemoryError("gp_DupGraph() failed.") # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":164 + * if not self.gp_IsEdge(e): + * raise RuntimeError( + * f"gp_GetNextEdge() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< + * ) * - * cdef Graph new_graph = Graph() */ - __pyx_t_3 = NULL; + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetNextEdge_failed_invalid_ed; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 45 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_DupGraph_failed}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_MemoryError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 159, __pyx_L1_error) - - /* "planarity/full/graph.pyx":158 - * def gp_DupGraph(self) -> Graph: - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: # <<<<<<<<<<<<<< - * raise MemoryError("gp_DupGraph() failed.") - * -*/ - } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 163, __pyx_L1_error) - /* "planarity/full/graph.pyx":161 - * raise MemoryError("gp_DupGraph() failed.") + /* "planarity/full/graph.pyx":162 * - * cdef Graph new_graph = Graph() # <<<<<<<<<<<<<< - * cgraphLib.gp_Free(&new_graph._theGraph) - * new_graph._theGraph = theGraph_dup + * def gp_GetNextEdge(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetNextEdge() failed: invalid edge index '{e}'." */ - __pyx_t_3 = NULL; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF((PyObject *)__pyx_t_2); } - __pyx_v_new_graph = ((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "planarity/full/graph.pyx":162 - * - * cdef Graph new_graph = Graph() - * cgraphLib.gp_Free(&new_graph._theGraph) # <<<<<<<<<<<<<< - * new_graph._theGraph = theGraph_dup - * -*/ - gp_Free((&__pyx_v_new_graph->_theGraph)); - - /* "planarity/full/graph.pyx":163 - * cdef Graph new_graph = Graph() - * cgraphLib.gp_Free(&new_graph._theGraph) - * new_graph._theGraph = theGraph_dup # <<<<<<<<<<<<<< - * - * return new_graph -*/ - __pyx_v_new_graph->_theGraph = __pyx_v_theGraph_dup; - /* "planarity/full/graph.pyx":165 - * new_graph._theGraph = theGraph_dup + /* "planarity/full/graph.pyx":167 + * ) * - * return new_graph # <<<<<<<<<<<<<< + * return cgraphLib.gp_GetNextEdge(self._theGraph, e) # <<<<<<<<<<<<<< * - * def gp_Read(self, str infile_name): + * def gp_GetNeighbor(self, int e): */ - __Pyx_XDECREF((PyObject *)__pyx_r); - __Pyx_INCREF((PyObject *)__pyx_v_new_graph); - __pyx_r = __pyx_v_new_graph; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetNextEdge(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":156 - * raise RuntimeError(f"gp_CopyGraph() failed.") + /* "planarity/full/graph.pyx":161 + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: + * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* function exit code */ __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DupGraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNextEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_new_graph); - __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":167 - * return new_graph +/* "planarity/full/graph.pyx":169 + * return cgraphLib.gp_GetNextEdge(self._theGraph, e) * - * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = infile_name.encode('utf-8') + * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_39gp_Read(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_39gp_GetNeighbor(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_38gp_Read, "Graph.gp_Read(self, str infile_name)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_39gp_Read = {"gp_Read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_39gp_Read, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_38gp_Read}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_39gp_Read(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_38gp_GetNeighbor, "Graph.gp_GetNeighbor(self, int e)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_39gp_GetNeighbor = {"gp_GetNeighbor", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_39gp_GetNeighbor, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_38gp_GetNeighbor}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_39gp_GetNeighbor(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - PyObject *__pyx_v_infile_name = 0; + int __pyx_v_e; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif @@ -6276,7 +6482,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_Read (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetNeighbor (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -6286,215 +6492,215 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_infile_name,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 167, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 169, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 167, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 169, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Read", 0) < (0)) __PYX_ERR(0, 167, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetNeighbor", 0) < (0)) __PYX_ERR(0, 169, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Read", 1, 1, 1, i); __PYX_ERR(0, 167, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetNeighbor", 1, 1, 1, i); __PYX_ERR(0, 169, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 167, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 169, __pyx_L3_error) } - __pyx_v_infile_name = ((PyObject*)values[0]); + __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 169, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_Read", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 167, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_GetNeighbor", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 169, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Read", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNeighbor", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_infile_name), (&PyUnicode_Type), 1, "infile_name", 1))) __PYX_ERR(0, 167, __pyx_L1_error) - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_38gp_Read(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_infile_name); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_38gp_GetNeighbor(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - goto __pyx_L7_cleaned_up; - __pyx_L0:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_38gp_Read(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_infile_name) { - PyObject *__pyx_v_encoded = 0; - char const *__pyx_v_FileName; +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_38gp_GetNeighbor(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - char const *__pyx_t_2; + PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - size_t __pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_Read", 0); - - /* "planarity/full/graph.pyx":169 - * def gp_Read(self, str infile_name): - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = infile_name.encode('utf-8') # <<<<<<<<<<<<<< - * cdef const char *FileName = encoded - * -*/ - if (unlikely(__pyx_v_infile_name == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 169, __pyx_L1_error) - } - __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_infile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_encoded = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; + size_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_GetNeighbor", 0); /* "planarity/full/graph.pyx":170 - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = infile_name.encode('utf-8') - * cdef const char *FileName = encoded # <<<<<<<<<<<<<< - * - * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: -*/ - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L1_error) - __pyx_v_FileName = __pyx_t_2; - - /* "planarity/full/graph.pyx":172 - * cdef const char *FileName = encoded - * - * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_Read() failed.") * + * def gp_GetNeighbor(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetNeighbor() failed: invalid edge index '{e}'." */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_Read(__pyx_v_self->_theGraph, __pyx_v_FileName)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(__pyx_t_5)) { + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":173 - * - * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: - * raise RuntimeError(f"gp_Read() failed.") # <<<<<<<<<<<<<< - * - * def gp_Write(self, str outfile_name, str mode): + /* "planarity/full/graph.pyx":171 + * def gp_GetNeighbor(self, int e): + * if not self.gp_IsEdge(e): + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_GetNeighbor() failed: invalid edge index '{e}'." + * ) */ __pyx_t_3 = NULL; - __pyx_t_6 = 1; + + /* "planarity/full/graph.pyx":172 + * if not self.gp_IsEdge(e): + * raise RuntimeError( + * f"gp_GetNeighbor() failed: invalid edge index '{e}'." # <<<<<<<<<<<<<< + * ) + * +*/ + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetNeighbor_failed_invalid_ed; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 45 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 172, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_Read_failed}; - __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 173, __pyx_L1_error) + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 171, __pyx_L1_error) - /* "planarity/full/graph.pyx":172 - * cdef const char *FileName = encoded - * - * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError(f"gp_Read() failed.") + /* "planarity/full/graph.pyx":170 * + * def gp_GetNeighbor(self, int e): + * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetNeighbor() failed: invalid edge index '{e}'." */ } - /* "planarity/full/graph.pyx":167 - * return new_graph + /* "planarity/full/graph.pyx":175 + * ) * - * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = infile_name.encode('utf-8') + * return cgraphLib.gp_GetNeighbor(self._theGraph, e) # <<<<<<<<<<<<<< + * + * def gp_GetFirstEdge(self, int v): +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetNeighbor(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "planarity/full/graph.pyx":169 + * return cgraphLib.gp_GetNextEdge(self._theGraph, e) + * + * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Read", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetNeighbor", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_encoded); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":175 - * raise RuntimeError(f"gp_Read() failed.") +/* "planarity/full/graph.pyx":177 + * return cgraphLib.gp_GetNeighbor(self._theGraph, e) * - * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError( */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_41gp_Write(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_40gp_Write, "Graph.gp_Write(self, str outfile_name, str mode)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_41gp_Write = {"gp_Write", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_41gp_Write, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_40gp_Write}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_41gp_Write(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge, "Graph.gp_GetFirstEdge(self, int v)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge = {"gp_GetFirstEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - PyObject *__pyx_v_outfile_name = 0; - PyObject *__pyx_v_mode = 0; + int __pyx_v_v; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[2] = {0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_Write (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_GetFirstEdge (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -6504,372 +6710,401 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_outfile_name,&__pyx_mstate_global->__pyx_n_u_mode,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 175, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 177, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { - case 2: - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 175, __pyx_L3_error) - CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 175, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 177, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Write", 0) < (0)) __PYX_ERR(0, 175, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Write", 1, 2, 2, i); __PYX_ERR(0, 175, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetFirstEdge", 0) < (0)) __PYX_ERR(0, 177, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetFirstEdge", 1, 1, 1, i); __PYX_ERR(0, 177, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 2)) { + } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 175, __pyx_L3_error) - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 175, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 177, __pyx_L3_error) } - __pyx_v_outfile_name = ((PyObject*)values[0]); - __pyx_v_mode = ((PyObject*)values[1]); + __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_Write", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 175, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_GetFirstEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 177, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Write", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetFirstEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outfile_name), (&PyUnicode_Type), 1, "outfile_name", 1))) __PYX_ERR(0, 175, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mode), (&PyUnicode_Type), 1, "mode", 1))) __PYX_ERR(0, 175, __pyx_L1_error) - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_40gp_Write(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_outfile_name, __pyx_v_mode); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - goto __pyx_L7_cleaned_up; - __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_40gp_Write(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name, PyObject *__pyx_v_mode) { - PyObject *__pyx_v_mode_code = NULL; - PyObject *__pyx_v_encoded = 0; - char const *__pyx_v_theFileName; +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; + PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; + size_t __pyx_t_4; + int __pyx_t_5; int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8[3]; - size_t __pyx_t_9; - char const *__pyx_t_10; - int __pyx_t_11; + PyObject *__pyx_t_7[3]; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_Write", 0); + __Pyx_RefNannySetupContext("gp_GetFirstEdge", 0); - /* "planarity/full/graph.pyx":176 + /* "planarity/full/graph.pyx":178 * - * def gp_Write(self, str outfile_name, str mode): - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" # <<<<<<<<<<<<<< - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" - * else (cgraphLib.WRITE_G6 if mode == "g" -*/ - __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_a, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 176, __pyx_L1_error) - if (__pyx_t_2) { - __pyx_t_3 = __Pyx_PyLong_From_int(WRITE_ADJLIST); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __pyx_t_3; - __pyx_t_3 = 0; - } else { - - /* "planarity/full/graph.pyx":177 - * def gp_Write(self, str outfile_name, str mode): - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" # <<<<<<<<<<<<<< - * else (cgraphLib.WRITE_G6 if mode == "g" - * else None))) -*/ - __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_m, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 177, __pyx_L1_error) - if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyLong_From_int(WRITE_ADJMATRIX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __pyx_t_5; - __pyx_t_5 = 0; - } else { - - /* "planarity/full/graph.pyx":178 - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" - * else (cgraphLib.WRITE_G6 if mode == "g" # <<<<<<<<<<<<<< - * else None))) - * if not mode_code: -*/ - __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_g, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 178, __pyx_L1_error) - if (__pyx_t_6) { - __pyx_t_7 = __Pyx_PyLong_From_int(WRITE_G6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = __pyx_t_7; - __pyx_t_7 = 0; - } else { - - /* "planarity/full/graph.pyx":179 - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" - * else (cgraphLib.WRITE_G6 if mode == "g" - * else None))) # <<<<<<<<<<<<<< - * if not mode_code: - * raise ValueError( + * def gp_GetFirstEdge(self, int v): + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." */ - __Pyx_INCREF(Py_None); - __pyx_t_5 = Py_None; - } - __pyx_t_3 = __pyx_t_5; - __pyx_t_5 = 0; - } - __pyx_t_1 = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); } - __pyx_v_mode_code = __pyx_t_1; - __pyx_t_1 = 0; - - /* "planarity/full/graph.pyx":180 - * else (cgraphLib.WRITE_G6 if mode == "g" - * else None))) - * if not mode_code: # <<<<<<<<<<<<<< - * raise ValueError( - * f"Invalid graph format specifier \"{mode}\" is not one of " -*/ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_mode_code); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 180, __pyx_L1_error) - __pyx_t_4 = (!__pyx_t_2); - if (unlikely(__pyx_t_4)) { + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = (!__pyx_t_5); + if (unlikely(__pyx_t_6)) { - /* "planarity/full/graph.pyx":181 - * else None))) - * if not mode_code: - * raise ValueError( # <<<<<<<<<<<<<< - * f"Invalid graph format specifier \"{mode}\" is not one of " - * "'gam'." + /* "planarity/full/graph.pyx":179 + * def gp_GetFirstEdge(self, int v): + * if not self.gp_IsVertex(v): + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." + * ) */ __pyx_t_3 = NULL; - /* "planarity/full/graph.pyx":182 - * if not mode_code: - * raise ValueError( - * f"Invalid graph format specifier \"{mode}\" is not one of " # <<<<<<<<<<<<<< - * "'gam'." - * ) + /* "planarity/full/graph.pyx":180 + * if not self.gp_IsVertex(v): + * raise RuntimeError( + * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." # <<<<<<<<<<<<<< + * ) + * */ - __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_graph_format_specifier; - __pyx_t_8[1] = __pyx_t_5; - __pyx_t_8[2] = __pyx_mstate_global->__pyx_kp_u_is_not_one_of_gam; - __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, 32 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5) + 22, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5)); - if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9 = 1; + __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_GetFirstEdge_failed_invalid_v; + __pyx_t_7[1] = __pyx_t_2; + __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 48 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 181, __pyx_L1_error) + __PYX_ERR(0, 179, __pyx_L1_error) - /* "planarity/full/graph.pyx":180 - * else (cgraphLib.WRITE_G6 if mode == "g" - * else None))) - * if not mode_code: # <<<<<<<<<<<<<< - * raise ValueError( - * f"Invalid graph format specifier \"{mode}\" is not one of " + /* "planarity/full/graph.pyx":178 + * + * def gp_GetFirstEdge(self, int v): + * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." */ } - /* "planarity/full/graph.pyx":187 + /* "planarity/full/graph.pyx":183 + * ) * - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = outfile_name.encode('utf-8') # <<<<<<<<<<<<<< - * cdef const char *theFileName = encoded + * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) # <<<<<<<<<<<<<< * + * def gp_LowerBoundVertices(self): */ - if (unlikely(__pyx_v_outfile_name == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 187, __pyx_L1_error) - } - __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetFirstEdge(__pyx_v_self->_theGraph, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_v_encoded = ((PyObject*)__pyx_t_1); + __pyx_r = __pyx_t_1; __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":188 - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = outfile_name.encode('utf-8') - * cdef const char *theFileName = encoded # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":177 + * return cgraphLib.gp_GetNeighbor(self._theGraph, e) * - * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: + * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError( */ - __pyx_t_10 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L1_error) - __pyx_v_theFileName = __pyx_t_10; - /* "planarity/full/graph.pyx":190 - * cdef const char *theFileName = encoded + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetFirstEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "planarity/full/graph.pyx":185 + * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) * - * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_Write() of graph to '{outfile_name}' failed." + * def gp_LowerBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) + * +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices, "Graph.gp_LowerBoundVertices(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices = {"gp_LowerBoundVertices", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_LowerBoundVertices (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_LowerBoundVertices", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_LowerBoundVertices", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_LowerBoundVertices", 0); + + /* "planarity/full/graph.pyx":186 + * + * def gp_LowerBoundVertices(self): + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) # <<<<<<<<<<<<<< + * + * def gp_UpperBoundVertices(self): */ - __pyx_t_11 = __Pyx_PyLong_As_int(__pyx_v_mode_code); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyLong_From_int(gp_Write(__pyx_v_self->_theGraph, __pyx_v_theFileName, __pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_LowerBoundVertices(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 190, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__pyx_t_4)) { + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":191 + /* "planarity/full/graph.pyx":185 + * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + * + * def gp_LowerBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) * - * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_Write() of graph to '{outfile_name}' failed." - * ) */ - __pyx_t_7 = NULL; - /* "planarity/full/graph.pyx":192 - * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: - * raise RuntimeError( - * f"gp_Write() of graph to '{outfile_name}' failed." # <<<<<<<<<<<<<< - * ) + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_LowerBoundVertices", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "planarity/full/graph.pyx":188 + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) + * + * def gp_UpperBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) * */ - __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8[0] = __pyx_mstate_global->__pyx_kp_u_gp_Write_of_graph_to; - __pyx_t_8[1] = __pyx_t_1; - __pyx_t_8[2] = __pyx_mstate_global->__pyx_kp_u_failed; - __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, 24 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 9, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1)); - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 191, __pyx_L1_error) - /* "planarity/full/graph.pyx":190 - * cdef const char *theFileName = encoded +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices, "Graph.gp_UpperBoundVertices(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices = {"gp_UpperBoundVertices", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_UpperBoundVertices (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_UpperBoundVertices", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_UpperBoundVertices", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_UpperBoundVertices", 0); + + /* "planarity/full/graph.pyx":189 * - * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_Write() of graph to '{outfile_name}' failed." + * def gp_UpperBoundVertices(self): + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) # <<<<<<<<<<<<<< + * + * def gp_IsVertex(self, int v): */ - } + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(gp_UpperBoundVertices(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "planarity/full/graph.pyx":175 - * raise RuntimeError(f"gp_Read() failed.") + /* "planarity/full/graph.pyx":188 + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) + * + * def gp_UpperBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) * - * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Write", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_UpperBoundVertices", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_mode_code); - __Pyx_XDECREF(__pyx_v_encoded); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":195 - * ) - * - * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") +/* "planarity/full/graph.pyx":191 + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) + * + * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< + * return ( + * (v >= self.gp_LowerBoundVertices()) and */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_43gp_FindEdge(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_47gp_IsVertex(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_42gp_FindEdge, "Graph.gp_FindEdge(self, int u, int v)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_43gp_FindEdge = {"gp_FindEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_43gp_FindEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_42gp_FindEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_43gp_FindEdge(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_46gp_IsVertex, "Graph.gp_IsVertex(self, int v)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_47gp_IsVertex = {"gp_IsVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_47gp_IsVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_46gp_IsVertex}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_47gp_IsVertex(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_u; int __pyx_v_v; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[2] = {0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_FindEdge (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_IsVertex (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -6879,52 +7114,45 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_u,&__pyx_mstate_global->__pyx_n_u_v,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 195, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 191, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { - case 2: - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 195, __pyx_L3_error) - CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 195, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 191, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_FindEdge", 0) < (0)) __PYX_ERR(0, 195, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_FindEdge", 1, 2, 2, i); __PYX_ERR(0, 195, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_IsVertex", 0) < (0)) __PYX_ERR(0, 191, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_IsVertex", 1, 1, 1, i); __PYX_ERR(0, 191, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 2)) { + } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 195, __pyx_L3_error) - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 195, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 191, __pyx_L3_error) } - __pyx_v_u = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_u == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 195, __pyx_L3_error) - __pyx_v_v = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 195, __pyx_L3_error) + __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_FindEdge", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 195, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_IsVertex", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 191, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_FindEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_42gp_FindEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_u, __pyx_v_v); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_46gp_IsVertex(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -6934,170 +7162,117 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_FindEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_v) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_46gp_IsVertex(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_t_5; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; + int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_FindEdge", 0); + __Pyx_RefNannySetupContext("gp_IsVertex", 0); - /* "planarity/full/graph.pyx":196 + /* "planarity/full/graph.pyx":192 * - * def gp_FindEdge(self, int u, int v): - * if not self.gp_IsVertex(u): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{u}' is not a valid vertex label.") - * if not self.gp_IsVertex(v): -*/ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_u); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { - - /* "planarity/full/graph.pyx":197 - * def gp_FindEdge(self, int u, int v): - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * def gp_IsVertex(self, int v): + * return ( # <<<<<<<<<<<<<< + * (v >= self.gp_LowerBoundVertices()) and + * (v < self.gp_UpperBoundVertices()) and */ - __pyx_t_3 = NULL; - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_u, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 30, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); - /* "planarity/full/graph.pyx":196 - * - * def gp_FindEdge(self, int u, int v): - * if not self.gp_IsVertex(u): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{u}' is not a valid vertex label.") - * if not self.gp_IsVertex(v): + /* "planarity/full/graph.pyx":193 + * def gp_IsVertex(self, int v): + * return ( + * (v >= self.gp_LowerBoundVertices()) and # <<<<<<<<<<<<<< + * (v < self.gp_UpperBoundVertices()) and + * cgraphLib.gp_IsVertex(self._theGraph, v) */ + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_4); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; + __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_LowerBoundVertices, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 193, __pyx_L1_error) + if (__pyx_t_6) { + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + __Pyx_INCREF(__pyx_t_4); + __pyx_t_1 = __pyx_t_4; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L3_bool_binop_done; } - /* "planarity/full/graph.pyx":198 - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{v}' is not a valid vertex label.") - * + /* "planarity/full/graph.pyx":194 + * return ( + * (v >= self.gp_LowerBoundVertices()) and + * (v < self.gp_UpperBoundVertices()) and # <<<<<<<<<<<<<< + * cgraphLib.gp_IsVertex(self._theGraph, v) + * ) */ - __pyx_t_8 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_8); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = ((PyObject *)__pyx_v_self); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_5 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; + __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_UpperBoundVertices, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); } - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 198, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (!__pyx_t_6); - if (unlikely(__pyx_t_5)) { - - /* "planarity/full/graph.pyx":199 - * raise RuntimeError(f"'{u}' is not a valid vertex label.") - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") # <<<<<<<<<<<<<< - * - * return cgraphLib.gp_FindEdge(self._theGraph, u, v) -*/ - __pyx_t_3 = NULL; - __pyx_t_8 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; - __pyx_t_7[1] = __pyx_t_8; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; - __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8) + 30, 127); - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_4 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 199, __pyx_L1_error) - - /* "planarity/full/graph.pyx":198 - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{v}' is not a valid vertex label.") - * -*/ + __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 194, __pyx_L1_error) + if (__pyx_t_6) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = __pyx_t_2; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L3_bool_binop_done; } - /* "planarity/full/graph.pyx":201 - * raise RuntimeError(f"'{v}' is not a valid vertex label.") - * - * return cgraphLib.gp_FindEdge(self._theGraph, u, v) # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":195 + * (v >= self.gp_LowerBoundVertices()) and + * (v < self.gp_UpperBoundVertices()) and + * cgraphLib.gp_IsVertex(self._theGraph, v) # <<<<<<<<<<<<<< + * ) * - * def gp_GetVertexDegree(self, int v): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_FindEdge(__pyx_v_self->_theGraph, __pyx_v_u, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = gp_IsVertex(__pyx_v_self->_theGraph, __pyx_v_v); + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_L3_bool_binop_done:; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":195 - * ) + /* "planarity/full/graph.pyx":191 + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) * - * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< + * return ( + * (v >= self.gp_LowerBoundVertices()) and */ /* function exit code */ @@ -7105,8 +7280,8 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_FindEdge(struct __ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_FindEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_IsVertex", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -7114,209 +7289,133 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_42gp_FindEdge(struct __ return __pyx_r; } -/* "planarity/full/graph.pyx":203 - * return cgraphLib.gp_FindEdge(self._theGraph, u, v) +/* "planarity/full/graph.pyx":198 + * ) * - * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K23Search structures.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree, "Graph.gp_GetVertexDegree(self, int v)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree = {"gp_GetVertexDegree", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search, "Graph.gp_ExtendWith_K23Search(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search = {"gp_ExtendWith_K23Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_v; - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetVertexDegree (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_v,0}; - const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 203, __pyx_L3_error) - if (__pyx_kwds_len > 0) { - switch (__pyx_nargs) { - case 1: - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 203, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_GetVertexDegree", 0) < (0)) __PYX_ERR(0, 203, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_GetVertexDegree", 1, 1, 1, i); __PYX_ERR(0, 203, __pyx_L3_error) } - } - } else if (unlikely(__pyx_nargs != 1)) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 203, __pyx_L3_error) - } - __pyx_v_v = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 203, __pyx_L3_error) - } - goto __pyx_L6_skip; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_GetVertexDegree", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 203, __pyx_L3_error) - __pyx_L6_skip:; - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetVertexDegree", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_v); + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_ExtendWith_K23Search (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K23Search", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K23Search", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_v) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; + int __pyx_t_4; + size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetVertexDegree", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_K23Search", 0); - /* "planarity/full/graph.pyx":204 + /* "planarity/full/graph.pyx":199 * - * def gp_GetVertexDegree(self, int v): - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * def gp_ExtendWith_K23Search(self): + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K23Search structures.") * */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K23Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":205 - * def gp_GetVertexDegree(self, int v): - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":200 + * def gp_ExtendWith_K23Search(self): + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K23Search structures.") # <<<<<<<<<<<<<< * - * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) + * def gp_ExtendWith_K33Search(self): */ - __pyx_t_3 = NULL; - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u__2; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_vertex_label; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 1 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 30, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = 1; + __pyx_t_2 = NULL; + __pyx_t_5 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K23S}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); } - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 200, __pyx_L1_error) - /* "planarity/full/graph.pyx":204 + /* "planarity/full/graph.pyx":199 * - * def gp_GetVertexDegree(self, int v): - * if not self.gp_IsVertex(v): # <<<<<<<<<<<<<< - * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * def gp_ExtendWith_K23Search(self): + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K23Search structures.") * */ } - /* "planarity/full/graph.pyx":207 - * raise RuntimeError(f"'{v}' is not a valid vertex label.") - * - * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) # <<<<<<<<<<<<<< - * - * def gp_GetEdgeCapacity(self): -*/ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetVertexDegree(__pyx_v_self->_theGraph, __pyx_v_v)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "planarity/full/graph.pyx":203 - * return cgraphLib.gp_FindEdge(self._theGraph, u, v) + /* "planarity/full/graph.pyx":198 + * ) * - * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") + * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K23Search structures.") */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetVertexDegree", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K23Search", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -7324,25 +7423,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree(st return __pyx_r; } -/* "planarity/full/graph.pyx":209 - * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) - * - * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) +/* "planarity/full/graph.pyx":202 + * raise RuntimeError("Failed to extend graph with K23Search structures.") * + * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K33Search structures.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity, "Graph.gp_GetEdgeCapacity(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity = {"gp_GetEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search, "Graph.gp_ExtendWith_K33Search(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search = {"gp_ExtendWith_K33Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -7355,7 +7454,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_GetEdgeCapacity (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_K33Search (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -7364,52 +7463,93 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_GetEdgeCapacity", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K33Search", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_GetEdgeCapacity", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K33Search", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_GetEdgeCapacity", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_K33Search", 0); - /* "planarity/full/graph.pyx":210 + /* "planarity/full/graph.pyx":203 * - * def gp_GetEdgeCapacity(self): - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) # <<<<<<<<<<<<<< + * def gp_ExtendWith_K33Search(self): + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K33Search structures.") * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_GetEdgeCapacity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K33Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 203, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":209 - * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) + /* "planarity/full/graph.pyx":204 + * def gp_ExtendWith_K33Search(self): + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K33Search structures.") # <<<<<<<<<<<<<< * - * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) + * def gp_ExtendWith_K4Search(self): +*/ + __pyx_t_2 = NULL; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K33S}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 204, __pyx_L1_error) + + /* "planarity/full/graph.pyx":203 + * + * def gp_ExtendWith_K33Search(self): + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K33Search structures.") * */ + } + + /* "planarity/full/graph.pyx":202 + * raise RuntimeError("Failed to extend graph with K23Search structures.") + * + * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K33Search structures.") +*/ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_GetEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K33Search", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -7417,43 +7557,38 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity(st return __pyx_r; } -/* "planarity/full/graph.pyx":212 - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) +/* "planarity/full/graph.pyx":206 + * raise RuntimeError("Failed to extend graph with K33Search structures.") * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - * raise RuntimeError( + * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K4Search structures.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity, "Graph.gp_EnsureEdgeCapacity(self, int new_edge_capacity)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity = {"gp_EnsureEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search, "Graph.gp_ExtendWith_K4Search(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search = {"gp_ExtendWith_K4Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_new_edge_capacity; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_EnsureEdgeCapacity (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_K4Search (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -7462,149 +7597,83 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_new_edge_capacity,0}; - const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 212, __pyx_L3_error) - if (__pyx_kwds_len > 0) { - switch (__pyx_nargs) { - case 1: - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 212, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_EnsureEdgeCapacity", 0) < (0)) __PYX_ERR(0, 212, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_EnsureEdgeCapacity", 1, 1, 1, i); __PYX_ERR(0, 212, __pyx_L3_error) } - } - } else if (unlikely(__pyx_nargs != 1)) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 212, __pyx_L3_error) - } - __pyx_v_new_edge_capacity = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_new_edge_capacity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 212, __pyx_L3_error) - } - goto __pyx_L6_skip; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_EnsureEdgeCapacity", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 212, __pyx_L3_error) - __pyx_L6_skip:; - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EnsureEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_new_edge_capacity); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K4Search", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K4Search", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_new_edge_capacity) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5[3]; - PyObject *__pyx_t_6 = NULL; - size_t __pyx_t_7; + int __pyx_t_4; + size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_EnsureEdgeCapacity", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_K4Search", 0); - /* "planarity/full/graph.pyx":213 + /* "planarity/full/graph.pyx":207 + * + * def gp_ExtendWith_K4Search(self): + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K4Search structures.") * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * "gp_EnsureEdgeCapacity() failed to set edge capacity to " */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_EnsureEdgeCapacity(__pyx_v_self->_theGraph, __pyx_v_new_edge_capacity)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K4Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":214 - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - * raise RuntimeError( # <<<<<<<<<<<<<< - * "gp_EnsureEdgeCapacity() failed to set edge capacity to " - * f"{new_edge_capacity}.") -*/ - __pyx_t_2 = NULL; - - /* "planarity/full/graph.pyx":216 - * raise RuntimeError( - * "gp_EnsureEdgeCapacity() failed to set edge capacity to " - * f"{new_edge_capacity}.") # <<<<<<<<<<<<<< - * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): -*/ - __pyx_t_1 = __Pyx_PyUnicode_From_int(__pyx_v_new_edge_capacity, 0, ' ', 'd'); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_gp_EnsureEdgeCapacity_failed_to; - __pyx_t_5[1] = __pyx_t_1; - __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u__3; - - /* "planarity/full/graph.pyx":215 - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - * raise RuntimeError( - * "gp_EnsureEdgeCapacity() failed to set edge capacity to " # <<<<<<<<<<<<<< - * f"{new_edge_capacity}.") + /* "planarity/full/graph.pyx":208 + * def gp_ExtendWith_K4Search(self): + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K4Search structures.") # <<<<<<<<<<<<<< * + * def gp_Read(self, str infile_name): */ - __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 55 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 1, 127); - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = 1; + __pyx_t_2 = NULL; + __pyx_t_5 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K4Se}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 214, __pyx_L1_error) + __PYX_ERR(0, 208, __pyx_L1_error) - /* "planarity/full/graph.pyx":213 + /* "planarity/full/graph.pyx":207 + * + * def gp_ExtendWith_K4Search(self): + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with K4Search structures.") * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * "gp_EnsureEdgeCapacity() failed to set edge capacity to " */ } - /* "planarity/full/graph.pyx":212 - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) + /* "planarity/full/graph.pyx":206 + * raise RuntimeError("Failed to extend graph with K33Search structures.") * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - * raise RuntimeError( + * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K4Search structures.") */ /* function exit code */ @@ -7614,8 +7683,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_EnsureEdgeCapacity", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K4Search", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -7623,46 +7691,43 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity return __pyx_r; } -/* "planarity/full/graph.pyx":218 - * f"{new_edge_capacity}.") +/* "planarity/full/graph.pyx":210 + * raise RuntimeError("Failed to extend graph with K4Search structures.") * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< - * if ulink != 0 and ulink != 1: - * raise RuntimeError( + * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = infile_name.encode('utf-8') */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_51gp_AddEdge(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_55gp_Read(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_50gp_AddEdge, "Graph.gp_AddEdge(self, int u, int ulink, int v, int vlink)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_51gp_AddEdge = {"gp_AddEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_51gp_AddEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_50gp_AddEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_51gp_AddEdge(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_54gp_Read, "Graph.gp_Read(self, str infile_name)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_55gp_Read = {"gp_Read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_55gp_Read, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_54gp_Read}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_55gp_Read(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_u; - int __pyx_v_ulink; - int __pyx_v_v; - int __pyx_v_vlink; + PyObject *__pyx_v_infile_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[4] = {0,0,0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_AddEdge (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_Read (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -7672,384 +7737,215 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_u,&__pyx_mstate_global->__pyx_n_u_ulink,&__pyx_mstate_global->__pyx_n_u_v,&__pyx_mstate_global->__pyx_n_u_vlink,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_infile_name,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 218, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 210, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { - case 4: - values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 218, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 3: - values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 218, __pyx_L3_error) - CYTHON_FALLTHROUGH; - case 2: - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 218, __pyx_L3_error) - CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 218, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 210, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_AddEdge", 0) < (0)) __PYX_ERR(0, 218, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 4; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_AddEdge", 1, 4, 4, i); __PYX_ERR(0, 218, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Read", 0) < (0)) __PYX_ERR(0, 210, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Read", 1, 1, 1, i); __PYX_ERR(0, 210, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 4)) { + } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 218, __pyx_L3_error) - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 218, __pyx_L3_error) - values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 218, __pyx_L3_error) - values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 218, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 210, __pyx_L3_error) } - __pyx_v_u = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_u == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error) - __pyx_v_ulink = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_ulink == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error) - __pyx_v_v = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_v == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error) - __pyx_v_vlink = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_vlink == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error) + __pyx_v_infile_name = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_AddEdge", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 218, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_Read", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 210, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_AddEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Read", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_50gp_AddEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_u, __pyx_v_ulink, __pyx_v_v, __pyx_v_vlink); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_infile_name), (&PyUnicode_Type), 1, "infile_name", 1))) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_54gp_Read(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_infile_name); /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + goto __pyx_L7_cleaned_up; + __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } + __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_50gp_AddEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_u, int __pyx_v_ulink, int __pyx_v_v, int __pyx_v_vlink) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_Read(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_infile_name) { + PyObject *__pyx_v_encoded = 0; + char const *__pyx_v_FileName; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_1 = NULL; + char const *__pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5[3]; - PyObject *__pyx_t_6 = NULL; - size_t __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10[9]; - PyObject *__pyx_t_11 = NULL; + int __pyx_t_5; + size_t __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_AddEdge", 0); - - /* "planarity/full/graph.pyx":219 - * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): - * if ulink != 0 and ulink != 1: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Invalid link index for ulink: '{ulink}'." -*/ - switch (__pyx_v_ulink) { - case 0: - case 1: - __pyx_t_1 = 0; - break; - default: - __pyx_t_1 = 1; - break; - } - if (unlikely(__pyx_t_1)) { - - /* "planarity/full/graph.pyx":220 - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): - * if ulink != 0 and ulink != 1: - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"Invalid link index for ulink: '{ulink}'." - * ) -*/ - __pyx_t_3 = NULL; - - /* "planarity/full/graph.pyx":221 - * if ulink != 0 and ulink != 1: - * raise RuntimeError( - * f"Invalid link index for ulink: '{ulink}'." # <<<<<<<<<<<<<< - * ) - * if vlink != 0 and vlink != 1: -*/ - __pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_ulink, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_link_index_for_ulink; - __pyx_t_5[1] = __pyx_t_4; - __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 31 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4) + 2, 127); - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_7 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 220, __pyx_L1_error) - - /* "planarity/full/graph.pyx":219 - * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): - * if ulink != 0 and ulink != 1: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Invalid link index for ulink: '{ulink}'." -*/ - } - - /* "planarity/full/graph.pyx":223 - * f"Invalid link index for ulink: '{ulink}'." - * ) - * if vlink != 0 and vlink != 1: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Invalid link index for vlink: '{vlink}'." -*/ - switch (__pyx_v_vlink) { - case 0: - case 1: - __pyx_t_1 = 0; - break; - default: - __pyx_t_1 = 1; - break; - } - if (unlikely(__pyx_t_1)) { - - /* "planarity/full/graph.pyx":224 - * ) - * if vlink != 0 and vlink != 1: - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"Invalid link index for vlink: '{vlink}'." - * ) -*/ - __pyx_t_6 = NULL; - - /* "planarity/full/graph.pyx":225 - * if vlink != 0 and vlink != 1: - * raise RuntimeError( - * f"Invalid link index for vlink: '{vlink}'." # <<<<<<<<<<<<<< - * ) - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: -*/ - __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_vlink, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_link_index_for_vlink; - __pyx_t_5[1] = __pyx_t_3; - __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, 31 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 2, 127); - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_7 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 224, __pyx_L1_error) + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_Read", 0); - /* "planarity/full/graph.pyx":223 - * f"Invalid link index for ulink: '{ulink}'." - * ) - * if vlink != 0 and vlink != 1: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Invalid link index for vlink: '{vlink}'." + /* "planarity/full/graph.pyx":212 + * def gp_Read(self, str infile_name): + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = infile_name.encode('utf-8') # <<<<<<<<<<<<<< + * cdef const char *FileName = encoded + * */ + if (unlikely(__pyx_v_infile_name == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); + __PYX_ERR(0, 212, __pyx_L1_error) } + __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_infile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_encoded = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; - /* "planarity/full/graph.pyx":227 - * f"Invalid link index for vlink: '{vlink}'." - * ) - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " -*/ - __pyx_t_2 = __Pyx_PyLong_From_int(gp_AddEdge(__pyx_v_self->_theGraph, __pyx_v_u, __pyx_v_ulink, __pyx_v_v, __pyx_v_vlink)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 227, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 227, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(__pyx_t_1)) { - - /* "planarity/full/graph.pyx":228 - * ) - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " - * f"and vlink = {vlink}." -*/ - __pyx_t_4 = NULL; - - /* "planarity/full/graph.pyx":229 - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: - * raise RuntimeError( - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " # <<<<<<<<<<<<<< - * f"and vlink = {vlink}." - * ) + /* "planarity/full/graph.pyx":213 + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = infile_name.encode('utf-8') + * cdef const char *FileName = encoded # <<<<<<<<<<<<<< + * + * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: */ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_u, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_v, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = __Pyx_PyUnicode_From_int(__pyx_v_ulink, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_v_FileName = __pyx_t_2; - /* "planarity/full/graph.pyx":230 - * raise RuntimeError( - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " - * f"and vlink = {vlink}." # <<<<<<<<<<<<<< - * ) + /* "planarity/full/graph.pyx":215 + * cdef const char *FileName = encoded + * + * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_Read() failed.") * */ - __pyx_t_9 = __Pyx_PyUnicode_From_int(__pyx_v_vlink, 0, ' ', 'd'); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 230, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10[0] = __pyx_mstate_global->__pyx_kp_u_Unable_to_add_edge_u_v; - __pyx_t_10[1] = __pyx_t_2; - __pyx_t_10[2] = __pyx_mstate_global->__pyx_kp_u__4; - __pyx_t_10[3] = __pyx_t_3; - __pyx_t_10[4] = __pyx_mstate_global->__pyx_kp_u_with_ulink; - __pyx_t_10[5] = __pyx_t_8; - __pyx_t_10[6] = __pyx_mstate_global->__pyx_kp_u_and_vlink; - __pyx_t_10[7] = __pyx_t_9; - __pyx_t_10[8] = __pyx_mstate_global->__pyx_kp_u__3; + __pyx_t_1 = __Pyx_PyLong_From_int(gp_Read(__pyx_v_self->_theGraph, __pyx_v_FileName)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 215, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 215, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(__pyx_t_5)) { - /* "planarity/full/graph.pyx":229 - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: - * raise RuntimeError( - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " # <<<<<<<<<<<<<< - * f"and vlink = {vlink}." - * ) + /* "planarity/full/graph.pyx":216 + * + * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: + * raise RuntimeError(f"gp_Read() failed.") # <<<<<<<<<<<<<< + * + * def gp_Write(self, str outfile_name, str mode): */ - __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_10, 9, 29 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 15 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8) + 13 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9) + 1, 127); - if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_7 = 1; + __pyx_t_3 = NULL; + __pyx_t_6 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_11}; - __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_gp_Read_failed}; + __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); } - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 228, __pyx_L1_error) + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 216, __pyx_L1_error) - /* "planarity/full/graph.pyx":227 - * f"Invalid link index for vlink: '{vlink}'." - * ) - * if cgraphLib.gp_AddEdge(self._theGraph, u, ulink, v, vlink) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"Unable to add edge (u, v) = ({u}, {v}) with ulink = {ulink} " + /* "planarity/full/graph.pyx":215 + * cdef const char *FileName = encoded + * + * if cgraphLib.gp_Read(self._theGraph, FileName) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError(f"gp_Read() failed.") + * */ } - /* "planarity/full/graph.pyx":218 - * f"{new_edge_capacity}.") + /* "planarity/full/graph.pyx":210 + * raise RuntimeError("Failed to extend graph with K4Search structures.") * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< - * if ulink != 0 and ulink != 1: - * raise RuntimeError( + * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = infile_name.encode('utf-8') */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_AddEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Read", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_encoded); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":233 - * ) +/* "planarity/full/graph.pyx":218 + * raise RuntimeError(f"gp_Read() failed.") * - * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_53gp_DeleteEdge(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_57gp_Write(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_52gp_DeleteEdge, "Graph.gp_DeleteEdge(self, int e)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_53gp_DeleteEdge = {"gp_DeleteEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_53gp_DeleteEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_52gp_DeleteEdge}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_53gp_DeleteEdge(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_56gp_Write, "Graph.gp_Write(self, str outfile_name, str mode)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_57gp_Write = {"gp_Write", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_57gp_Write, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_56gp_Write}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_57gp_Write(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - int __pyx_v_e; + PyObject *__pyx_v_outfile_name = 0; + PyObject *__pyx_v_mode = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; + PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_DeleteEdge (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_Write (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -8059,295 +7955,314 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_e,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_outfile_name,&__pyx_mstate_global->__pyx_n_u_mode,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 233, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 218, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { + case 2: + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 218, __pyx_L3_error) + CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 233, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 218, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_DeleteEdge", 0) < (0)) __PYX_ERR(0, 233, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_DeleteEdge", 1, 1, 1, i); __PYX_ERR(0, 233, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Write", 0) < (0)) __PYX_ERR(0, 218, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Write", 1, 2, 2, i); __PYX_ERR(0, 218, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 1)) { + } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 233, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 218, __pyx_L3_error) + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 218, __pyx_L3_error) } - __pyx_v_e = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_e == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L3_error) + __pyx_v_outfile_name = ((PyObject*)values[0]); + __pyx_v_mode = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_DeleteEdge", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 233, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_Write", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 218, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DeleteEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Write", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_52gp_DeleteEdge(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_e); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outfile_name), (&PyUnicode_Type), 1, "outfile_name", 1))) __PYX_ERR(0, 218, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mode), (&PyUnicode_Type), 1, "mode", 1))) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_56gp_Write(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_outfile_name, __pyx_v_mode); /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + goto __pyx_L7_cleaned_up; + __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } + __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_52gp_DeleteEdge(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_e) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_Write(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name, PyObject *__pyx_v_mode) { + PyObject *__pyx_v_mode_code = NULL; + PyObject *__pyx_v_encoded = 0; + char const *__pyx_v_theFileName; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - size_t __pyx_t_4; - int __pyx_t_5; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; int __pyx_t_6; - PyObject *__pyx_t_7[3]; - PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8[3]; + size_t __pyx_t_9; + char const *__pyx_t_10; + int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_DeleteEdge", 0); + __Pyx_RefNannySetupContext("gp_Write", 0); + + /* "planarity/full/graph.pyx":219 + * + * def gp_Write(self, str outfile_name, str mode): + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" # <<<<<<<<<<<<<< + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + * else (cgraphLib.WRITE_G6 if mode == "g" +*/ + __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_a, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 219, __pyx_L1_error) + if (__pyx_t_2) { + __pyx_t_3 = __Pyx_PyLong_From_int(WRITE_ADJLIST); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __pyx_t_3; + __pyx_t_3 = 0; + } else { + + /* "planarity/full/graph.pyx":220 + * def gp_Write(self, str outfile_name, str mode): + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" # <<<<<<<<<<<<<< + * else (cgraphLib.WRITE_G6 if mode == "g" + * else None))) +*/ + __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_m, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 220, __pyx_L1_error) + if (__pyx_t_4) { + __pyx_t_5 = __Pyx_PyLong_From_int(WRITE_ADJMATRIX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __pyx_t_5; + __pyx_t_5 = 0; + } else { + + /* "planarity/full/graph.pyx":221 + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + * else (cgraphLib.WRITE_G6 if mode == "g" # <<<<<<<<<<<<<< + * else None))) + * if not mode_code: +*/ + __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_mode, __pyx_mstate_global->__pyx_n_u_g, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 221, __pyx_L1_error) + if (__pyx_t_6) { + __pyx_t_7 = __Pyx_PyLong_From_int(WRITE_G6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = __pyx_t_7; + __pyx_t_7 = 0; + } else { + + /* "planarity/full/graph.pyx":222 + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + * else (cgraphLib.WRITE_G6 if mode == "g" + * else None))) # <<<<<<<<<<<<<< + * if not mode_code: + * raise ValueError( +*/ + __Pyx_INCREF(Py_None); + __pyx_t_5 = Py_None; + } + __pyx_t_3 = __pyx_t_5; + __pyx_t_5 = 0; + } + __pyx_t_1 = __pyx_t_3; + __pyx_t_3 = 0; + } + __pyx_v_mode_code = __pyx_t_1; + __pyx_t_1 = 0; - /* "planarity/full/graph.pyx":234 - * - * def gp_DeleteEdge(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_DeleteEdge() failed: invalid edge '{e}'." + /* "planarity/full/graph.pyx":223 + * else (cgraphLib.WRITE_G6 if mode == "g" + * else None))) + * if not mode_code: # <<<<<<<<<<<<<< + * raise ValueError( + * f"Invalid graph format specifier \"{mode}\" is not one of " */ - __pyx_t_2 = ((PyObject *)__pyx_v_self); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = (!__pyx_t_5); - if (unlikely(__pyx_t_6)) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_mode_code); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 223, __pyx_L1_error) + __pyx_t_4 = (!__pyx_t_2); + if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":235 - * def gp_DeleteEdge(self, int e): - * if not self.gp_IsEdge(e): - * raise RuntimeError( # <<<<<<<<<<<<<< - * f"gp_DeleteEdge() failed: invalid edge '{e}'." - * ) + /* "planarity/full/graph.pyx":224 + * else None))) + * if not mode_code: + * raise ValueError( # <<<<<<<<<<<<<< + * f"Invalid graph format specifier \"{mode}\" is not one of " + * "'gam'." */ __pyx_t_3 = NULL; - /* "planarity/full/graph.pyx":236 - * if not self.gp_IsEdge(e): - * raise RuntimeError( - * f"gp_DeleteEdge() failed: invalid edge '{e}'." # <<<<<<<<<<<<<< - * ) - * + /* "planarity/full/graph.pyx":225 + * if not mode_code: + * raise ValueError( + * f"Invalid graph format specifier \"{mode}\" is not one of " # <<<<<<<<<<<<<< + * "'gam'." + * ) */ - __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_e, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7[0] = __pyx_mstate_global->__pyx_kp_u_gp_DeleteEdge_failed_invalid_edg; - __pyx_t_7[1] = __pyx_t_2; - __pyx_t_7[2] = __pyx_mstate_global->__pyx_kp_u_; - __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, 38 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 2, 127); - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = 1; + __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_v_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_8[0] = __pyx_mstate_global->__pyx_kp_u_Invalid_graph_format_specifier; + __pyx_t_8[1] = __pyx_t_5; + __pyx_t_8[2] = __pyx_mstate_global->__pyx_kp_u_is_not_one_of_gam; + __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, 32 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5) + 22, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5)); + if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_9 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_7}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 235, __pyx_L1_error) + __PYX_ERR(0, 224, __pyx_L1_error) - /* "planarity/full/graph.pyx":234 - * - * def gp_DeleteEdge(self, int e): - * if not self.gp_IsEdge(e): # <<<<<<<<<<<<<< - * raise RuntimeError( - * f"gp_DeleteEdge() failed: invalid edge '{e}'." + /* "planarity/full/graph.pyx":223 + * else (cgraphLib.WRITE_G6 if mode == "g" + * else None))) + * if not mode_code: # <<<<<<<<<<<<<< + * raise ValueError( + * f"Invalid graph format specifier \"{mode}\" is not one of " */ } - /* "planarity/full/graph.pyx":239 - * ) + /* "planarity/full/graph.pyx":230 * - * return cgraphLib.gp_DeleteEdge(self._theGraph, e) # <<<<<<<<<<<<<< + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = outfile_name.encode('utf-8') # <<<<<<<<<<<<<< + * cdef const char *theFileName = encoded * - * def gp_ExtendWith_Planarity(self): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_int(gp_DeleteEdge(__pyx_v_self->_theGraph, __pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) + if (unlikely(__pyx_v_outfile_name == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); + __PYX_ERR(0, 230, __pyx_L1_error) + } + __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_v_encoded = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - - /* "planarity/full/graph.pyx":233 - * ) - * - * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( -*/ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DeleteEdge", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -/* "planarity/full/graph.pyx":241 - * return cgraphLib.gp_DeleteEdge(self._theGraph, e) + /* "planarity/full/graph.pyx":231 + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = outfile_name.encode('utf-8') + * cdef const char *theFileName = encoded # <<<<<<<<<<<<<< * - * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Planarity structures.") + * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: */ + __pyx_t_10 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L1_error) + __pyx_v_theFileName = __pyx_t_10; -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity, "Graph.gp_ExtendWith_Planarity(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity = {"gp_ExtendWith_Planarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ExtendWith_Planarity (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_Planarity", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_Planarity", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - size_t __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_ExtendWith_Planarity", 0); - - /* "planarity/full/graph.pyx":242 - * - * def gp_ExtendWith_Planarity(self): - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with Planarity structures.") + /* "planarity/full/graph.pyx":233 + * cdef const char *theFileName = encoded * + * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_Write() of graph to '{outfile_name}' failed." */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_Planarity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyLong_As_int(__pyx_v_mode_code); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_Write(__pyx_v_self->_theGraph, __pyx_v_theFileName, __pyx_t_11)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_7, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 242, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":243 - * def gp_ExtendWith_Planarity(self): - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Planarity structures.") # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":234 * - * def gp_ExtendWith_DrawPlanar(self): + * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: + * raise RuntimeError( # <<<<<<<<<<<<<< + * f"gp_Write() of graph to '{outfile_name}' failed." + * ) */ - __pyx_t_2 = NULL; - __pyx_t_5 = 1; + __pyx_t_7 = NULL; + + /* "planarity/full/graph.pyx":235 + * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: + * raise RuntimeError( + * f"gp_Write() of graph to '{outfile_name}' failed." # <<<<<<<<<<<<<< + * ) + * +*/ + __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8[0] = __pyx_mstate_global->__pyx_kp_u_gp_Write_of_graph_to; + __pyx_t_8[1] = __pyx_t_1; + __pyx_t_8[2] = __pyx_mstate_global->__pyx_kp_u_failed; + __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, 24 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 9, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1)); + if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_Plan}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) + PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 243, __pyx_L1_error) + __PYX_ERR(0, 234, __pyx_L1_error) - /* "planarity/full/graph.pyx":242 - * - * def gp_ExtendWith_Planarity(self): - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with Planarity structures.") + /* "planarity/full/graph.pyx":233 + * cdef const char *theFileName = encoded * + * if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError( + * f"gp_Write() of graph to '{outfile_name}' failed." */ } - /* "planarity/full/graph.pyx":241 - * return cgraphLib.gp_DeleteEdge(self._theGraph, e) + /* "planarity/full/graph.pyx":218 + * raise RuntimeError(f"gp_Read() failed.") * - * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Planarity structures.") + * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" */ /* function exit code */ @@ -8355,18 +8270,21 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planari goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_Planarity", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_Write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_mode_code); + __Pyx_XDECREF(__pyx_v_encoded); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "planarity/full/graph.pyx":245 - * raise RuntimeError("Failed to extend graph with Planarity structures.") +/* "planarity/full/graph.pyx":238 + * ) * * def gp_ExtendWith_DrawPlanar(self): # <<<<<<<<<<<<<< * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: @@ -8374,16 +8292,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planari */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar, "Graph.gp_ExtendWith_DrawPlanar(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar = {"gp_ExtendWith_DrawPlanar", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar, "Graph.gp_ExtendWith_DrawPlanar(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar = {"gp_ExtendWith_DrawPlanar", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -8409,14 +8327,14 @@ PyObject *__pyx_args, PyObject *__pyx_kwds const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_DrawPlanar", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -8429,25 +8347,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPla int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_ExtendWith_DrawPlanar", 0); - /* "planarity/full/graph.pyx":246 + /* "planarity/full/graph.pyx":239 * * def gp_ExtendWith_DrawPlanar(self): * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: # <<<<<<<<<<<<<< * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") * */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_DrawPlanar(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_DrawPlanar(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":247 + /* "planarity/full/graph.pyx":240 * def gp_ExtendWith_DrawPlanar(self): * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") # <<<<<<<<<<<<<< @@ -8460,14 +8378,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPla PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_Draw}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 247, __pyx_L1_error) + __PYX_ERR(0, 240, __pyx_L1_error) - /* "planarity/full/graph.pyx":246 + /* "planarity/full/graph.pyx":239 * * def gp_ExtendWith_DrawPlanar(self): * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: # <<<<<<<<<<<<<< @@ -8476,8 +8394,8 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPla */ } - /* "planarity/full/graph.pyx":245 - * raise RuntimeError("Failed to extend graph with Planarity structures.") + /* "planarity/full/graph.pyx":238 + * ) * * def gp_ExtendWith_DrawPlanar(self): # <<<<<<<<<<<<<< * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: @@ -8499,7 +8417,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPla return __pyx_r; } -/* "planarity/full/graph.pyx":249 +/* "planarity/full/graph.pyx":242 * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") * * def gp_DrawPlanar_RenderToFile(self, str outfile_name): # <<<<<<<<<<<<<< @@ -8508,16 +8426,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPla */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile, "Graph.gp_DrawPlanar_RenderToFile(self, str outfile_name)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile = {"gp_DrawPlanar_RenderToFile", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile, "Graph.gp_DrawPlanar_RenderToFile(self, str outfile_name)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile = {"gp_DrawPlanar_RenderToFile", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -8547,32 +8465,32 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_outfile_name,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 249, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 242, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 249, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 242, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_DrawPlanar_RenderToFile", 0) < (0)) __PYX_ERR(0, 249, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_DrawPlanar_RenderToFile", 0) < (0)) __PYX_ERR(0, 242, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_DrawPlanar_RenderToFile", 1, 1, 1, i); __PYX_ERR(0, 249, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_DrawPlanar_RenderToFile", 1, 1, 1, i); __PYX_ERR(0, 242, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 249, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 242, __pyx_L3_error) } __pyx_v_outfile_name = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_DrawPlanar_RenderToFile", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 249, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_DrawPlanar_RenderToFile", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 242, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -8583,8 +8501,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outfile_name), (&PyUnicode_Type), 1, "outfile_name", 1))) __PYX_ERR(0, 249, __pyx_L1_error) - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_outfile_name); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outfile_name), (&PyUnicode_Type), 1, "outfile_name", 1))) __PYX_ERR(0, 242, __pyx_L1_error) + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_outfile_name); /* function exit code */ goto __pyx_L0; @@ -8603,7 +8521,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, PyObject *__pyx_v_outfile_name) { PyObject *__pyx_v_encoded = 0; char const *__pyx_v_theFileName; PyObject *__pyx_r = NULL; @@ -8621,7 +8539,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_DrawPlanar_RenderToFile", 0); - /* "planarity/full/graph.pyx":251 + /* "planarity/full/graph.pyx":244 * def gp_DrawPlanar_RenderToFile(self, str outfile_name): * # Convert Python str to UTF-8 encoded bytes, and then to const char * * cdef bytes encoded = outfile_name.encode('utf-8') # <<<<<<<<<<<<<< @@ -8630,42 +8548,42 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT */ if (unlikely(__pyx_v_outfile_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 251, __pyx_L1_error) + __PYX_ERR(0, 244, __pyx_L1_error) } - __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_encoded = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "planarity/full/graph.pyx":252 + /* "planarity/full/graph.pyx":245 * # Convert Python str to UTF-8 encoded bytes, and then to const char * * cdef bytes encoded = outfile_name.encode('utf-8') * cdef const char *theFileName = encoded # <<<<<<<<<<<<<< * * if cgraphLib.gp_DrawPlanar_RenderToFile(self._theGraph, theFileName) != OK: */ - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_encoded); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 245, __pyx_L1_error) __pyx_v_theFileName = __pyx_t_2; - /* "planarity/full/graph.pyx":254 + /* "planarity/full/graph.pyx":247 * cdef const char *theFileName = encoded * * if cgraphLib.gp_DrawPlanar_RenderToFile(self._theGraph, theFileName) != OK: # <<<<<<<<<<<<<< * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") * */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_DrawPlanar_RenderToFile(__pyx_v_self->_theGraph, __pyx_v_theFileName)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_DrawPlanar_RenderToFile(__pyx_v_self->_theGraph, __pyx_v_theFileName)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(__pyx_t_5)) { - /* "planarity/full/graph.pyx":255 + /* "planarity/full/graph.pyx":248 * * if cgraphLib.gp_DrawPlanar_RenderToFile(self._theGraph, theFileName) != OK: * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") # <<<<<<<<<<<<<< @@ -8673,13 +8591,13 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT * def gp_DrawPlanar_RenderToString(self): */ __pyx_t_3 = NULL; - __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_outfile_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6[0] = __pyx_mstate_global->__pyx_kp_u_Failed_to_render_embedding_to_fi; __pyx_t_6[1] = __pyx_t_1; - __pyx_t_6[2] = __pyx_mstate_global->__pyx_kp_u_; + __pyx_t_6[2] = __pyx_mstate_global->__pyx_kp_u__3; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, 36 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 2, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1)); - if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 255, __pyx_L1_error) + if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = 1; @@ -8688,14 +8606,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 255, __pyx_L1_error) + __PYX_ERR(0, 248, __pyx_L1_error) - /* "planarity/full/graph.pyx":254 + /* "planarity/full/graph.pyx":247 * cdef const char *theFileName = encoded * * if cgraphLib.gp_DrawPlanar_RenderToFile(self._theGraph, theFileName) != OK: # <<<<<<<<<<<<<< @@ -8704,7 +8622,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT */ } - /* "planarity/full/graph.pyx":249 + /* "planarity/full/graph.pyx":242 * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") * * def gp_DrawPlanar_RenderToFile(self, str outfile_name): # <<<<<<<<<<<<<< @@ -8729,7 +8647,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT return __pyx_r; } -/* "planarity/full/graph.pyx":257 +/* "planarity/full/graph.pyx":250 * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") * * def gp_DrawPlanar_RenderToString(self): # <<<<<<<<<<<<<< @@ -8738,16 +8656,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderT */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString, "Graph.gp_DrawPlanar_RenderToString(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString = {"gp_DrawPlanar_RenderToString", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString, "Graph.gp_DrawPlanar_RenderToString(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString = {"gp_DrawPlanar_RenderToString", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -8773,14 +8691,14 @@ PyObject *__pyx_args, PyObject *__pyx_kwds const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_DrawPlanar_RenderToString", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { char *__pyx_v_renditionString; PyObject *__pyx_v_string_conversion_error = NULL; PyObject *__pyx_r = NULL; @@ -8811,7 +8729,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_DrawPlanar_RenderToString", 0); - /* "planarity/full/graph.pyx":258 + /* "planarity/full/graph.pyx":251 * * def gp_DrawPlanar_RenderToString(self): * cdef char* renditionString = NULL # <<<<<<<<<<<<<< @@ -8820,25 +8738,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT */ __pyx_v_renditionString = NULL; - /* "planarity/full/graph.pyx":259 + /* "planarity/full/graph.pyx":252 * def gp_DrawPlanar_RenderToString(self): * cdef char* renditionString = NULL * if cgraphLib.gp_DrawPlanar_RenderToString(self._theGraph, &renditionString) != OK: # <<<<<<<<<<<<<< * raise RuntimeError(f"Failed to render embedding to C string.") * */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_DrawPlanar_RenderToString(__pyx_v_self->_theGraph, (&__pyx_v_renditionString))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_DrawPlanar_RenderToString(__pyx_v_self->_theGraph, (&__pyx_v_renditionString))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 259, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":260 + /* "planarity/full/graph.pyx":253 * cdef char* renditionString = NULL * if cgraphLib.gp_DrawPlanar_RenderToString(self._theGraph, &renditionString) != OK: * raise RuntimeError(f"Failed to render embedding to C string.") # <<<<<<<<<<<<<< @@ -8851,14 +8769,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_render_embedding_to_C}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 260, __pyx_L1_error) + __PYX_ERR(0, 253, __pyx_L1_error) - /* "planarity/full/graph.pyx":259 + /* "planarity/full/graph.pyx":252 * def gp_DrawPlanar_RenderToString(self): * cdef char* renditionString = NULL * if cgraphLib.gp_DrawPlanar_RenderToString(self._theGraph, &renditionString) != OK: # <<<<<<<<<<<<<< @@ -8867,7 +8785,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT */ } - /* "planarity/full/graph.pyx":262 + /* "planarity/full/graph.pyx":255 * raise RuntimeError(f"Failed to render embedding to C string.") * * try: # <<<<<<<<<<<<<< @@ -8884,7 +8802,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { - /* "planarity/full/graph.pyx":263 + /* "planarity/full/graph.pyx":256 * * try: * return renditionString.decode('ascii') # <<<<<<<<<<<<<< @@ -8892,14 +8810,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT * raise RuntimeError( */ __Pyx_XDECREF(__pyx_r); - __pyx_t_9 = __Pyx_ssize_strlen(__pyx_v_renditionString); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 263, __pyx_L7_error) - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_renditionString, 0, __pyx_t_9, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L7_error) + __pyx_t_9 = __Pyx_ssize_strlen(__pyx_v_renditionString); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 256, __pyx_L7_error) + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_renditionString, 0, __pyx_t_9, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L11_try_return; - /* "planarity/full/graph.pyx":262 + /* "planarity/full/graph.pyx":255 * raise RuntimeError(f"Failed to render embedding to C string.") * * try: # <<<<<<<<<<<<<< @@ -8912,7 +8830,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "planarity/full/graph.pyx":264 + /* "planarity/full/graph.pyx":257 * try: * return renditionString.decode('ascii') * except Exception as string_conversion_error: # <<<<<<<<<<<<<< @@ -8922,7 +8840,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception)))); if (__pyx_t_10) { __Pyx_AddTraceback("planarity.full.graph.Graph.gp_DrawPlanar_RenderToString", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 264, __pyx_L9_except_error) + if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 257, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); @@ -8930,7 +8848,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT __pyx_v_string_conversion_error = __pyx_t_2; /*try:*/ { - /* "planarity/full/graph.pyx":265 + /* "planarity/full/graph.pyx":258 * return renditionString.decode('ascii') * except Exception as string_conversion_error: * raise RuntimeError( # <<<<<<<<<<<<<< @@ -8943,11 +8861,11 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_Failed_to_convert_C_string_to_Py}; __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L18_error) + if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 258, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); } - /* "planarity/full/graph.pyx":267 + /* "planarity/full/graph.pyx":260 * raise RuntimeError( * "Failed to convert C string to Python string." * ) from string_conversion_error # <<<<<<<<<<<<<< @@ -8956,10 +8874,10 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT */ __Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_string_conversion_error); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __PYX_ERR(0, 265, __pyx_L18_error) + __PYX_ERR(0, 258, __pyx_L18_error) } - /* "planarity/full/graph.pyx":264 + /* "planarity/full/graph.pyx":257 * try: * return renditionString.decode('ascii') * except Exception as string_conversion_error: # <<<<<<<<<<<<<< @@ -9002,7 +8920,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT } goto __pyx_L9_except_error; - /* "planarity/full/graph.pyx":262 + /* "planarity/full/graph.pyx":255 * raise RuntimeError(f"Failed to render embedding to C string.") * * try: # <<<<<<<<<<<<<< @@ -9024,7 +8942,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT } } - /* "planarity/full/graph.pyx":269 + /* "planarity/full/graph.pyx":262 * ) from string_conversion_error * finally: * free(renditionString) # <<<<<<<<<<<<<< @@ -9076,7 +8994,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT } } - /* "planarity/full/graph.pyx":257 + /* "planarity/full/graph.pyx":250 * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") * * def gp_DrawPlanar_RenderToString(self): # <<<<<<<<<<<<<< @@ -9100,7 +9018,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT return __pyx_r; } -/* "planarity/full/graph.pyx":271 +/* "planarity/full/graph.pyx":264 * free(renditionString) * * def gp_ExtendWith_Outerplanarity(self): # <<<<<<<<<<<<<< @@ -9109,16 +9027,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderT */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity, "Graph.gp_ExtendWith_Outerplanarity(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity = {"gp_ExtendWith_Outerplanarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity, "Graph.gp_ExtendWith_Outerplanarity(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity = {"gp_ExtendWith_Outerplanarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -9144,14 +9062,14 @@ PyObject *__pyx_args, PyObject *__pyx_kwds const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_Outerplanarity", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -9164,30 +9082,30 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerpl int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_ExtendWith_Outerplanarity", 0); - /* "planarity/full/graph.pyx":272 + /* "planarity/full/graph.pyx":265 * * def gp_ExtendWith_Outerplanarity(self): * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: # <<<<<<<<<<<<<< * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") * */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_Outerplanarity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_Outerplanarity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":273 + /* "planarity/full/graph.pyx":266 * def gp_ExtendWith_Outerplanarity(self): * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") # <<<<<<<<<<<<<< * - * def gp_ExtendWith_K23Search(self): + * def gp_ExtendWith_Planarity(self): */ __pyx_t_2 = NULL; __pyx_t_5 = 1; @@ -9195,296 +9113,28 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerpl PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_Oute}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 273, __pyx_L1_error) + __PYX_ERR(0, 266, __pyx_L1_error) - /* "planarity/full/graph.pyx":272 + /* "planarity/full/graph.pyx":265 * * def gp_ExtendWith_Outerplanarity(self): * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") - * -*/ - } - - /* "planarity/full/graph.pyx":271 - * free(renditionString) - * - * def gp_ExtendWith_Outerplanarity(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") -*/ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_Outerplanarity", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":275 - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") - * - * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K23Search structures.") -*/ - -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search, "Graph.gp_ExtendWith_K23Search(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search = {"gp_ExtendWith_K23Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ExtendWith_K23Search (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K23Search", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K23Search", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - size_t __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_ExtendWith_K23Search", 0); - - /* "planarity/full/graph.pyx":276 - * - * def gp_ExtendWith_K23Search(self): - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K23Search structures.") - * -*/ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K23Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 276, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__pyx_t_4)) { - - /* "planarity/full/graph.pyx":277 - * def gp_ExtendWith_K23Search(self): - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K23Search structures.") # <<<<<<<<<<<<<< - * - * def gp_ExtendWith_K33Search(self): -*/ - __pyx_t_2 = NULL; - __pyx_t_5 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K23S}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 277, __pyx_L1_error) - - /* "planarity/full/graph.pyx":276 - * - * def gp_ExtendWith_K23Search(self): - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K23Search structures.") - * -*/ - } - - /* "planarity/full/graph.pyx":275 - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") - * - * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K23Search structures.") -*/ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K23Search", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "planarity/full/graph.pyx":279 - * raise RuntimeError("Failed to extend graph with K23Search structures.") - * - * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K33Search structures.") -*/ - -/* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search, "Graph.gp_ExtendWith_K33Search(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search = {"gp_ExtendWith_K33Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL - CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif - CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ExtendWith_K33Search (wrapper)", 0); - #if !CYTHON_METH_FASTCALL - #if CYTHON_ASSUME_SAFE_SIZE - __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); - #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; - #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K33Search", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K33Search", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - size_t __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_ExtendWith_K33Search", 0); - - /* "planarity/full/graph.pyx":280 - * - * def gp_ExtendWith_K33Search(self): - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K33Search structures.") - * -*/ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K33Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__pyx_t_4)) { - - /* "planarity/full/graph.pyx":281 - * def gp_ExtendWith_K33Search(self): - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K33Search structures.") # <<<<<<<<<<<<<< - * - * def gp_ExtendWith_K4Search(self): -*/ - __pyx_t_2 = NULL; - __pyx_t_5 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K33S}; - __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - } - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 281, __pyx_L1_error) - - /* "planarity/full/graph.pyx":280 - * - * def gp_ExtendWith_K33Search(self): - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K33Search structures.") + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") * */ } - /* "planarity/full/graph.pyx":279 - * raise RuntimeError("Failed to extend graph with K23Search structures.") + /* "planarity/full/graph.pyx":264 + * free(renditionString) * - * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K33Search structures.") + * def gp_ExtendWith_Outerplanarity(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") */ /* function exit code */ @@ -9494,7 +9144,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Sear __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K33Search", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_Outerplanarity", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -9502,25 +9152,25 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Sear return __pyx_r; } -/* "planarity/full/graph.pyx":283 - * raise RuntimeError("Failed to extend graph with K33Search structures.") +/* "planarity/full/graph.pyx":268 + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") * - * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K4Search structures.") + * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Planarity structures.") */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search, "Graph.gp_ExtendWith_K4Search(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search = {"gp_ExtendWith_K4Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity, "Graph.gp_ExtendWith_Planarity(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity = {"gp_ExtendWith_Planarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -9533,7 +9183,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gp_ExtendWith_K4Search (wrapper)", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_Planarity (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); @@ -9542,18 +9192,18 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_K4Search", 1, 0, 0, __pyx_nargs); return NULL; } + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("gp_ExtendWith_Planarity", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_K4Search", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("gp_ExtendWith_Planarity", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -9564,61 +9214,61 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Searc int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gp_ExtendWith_K4Search", 0); + __Pyx_RefNannySetupContext("gp_ExtendWith_Planarity", 0); - /* "planarity/full/graph.pyx":284 + /* "planarity/full/graph.pyx":269 * - * def gp_ExtendWith_K4Search(self): - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K4Search structures.") + * def gp_ExtendWith_Planarity(self): + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with Planarity structures.") * */ - __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_K4Search(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_int(gp_ExtendWith_Planarity(__pyx_v_self->_theGraph)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { - /* "planarity/full/graph.pyx":285 - * def gp_ExtendWith_K4Search(self): - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K4Search structures.") # <<<<<<<<<<<<<< + /* "planarity/full/graph.pyx":270 + * def gp_ExtendWith_Planarity(self): + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Planarity structures.") # <<<<<<<<<<<<<< * * def gp_Embed(self, int embedFlags) -> int: */ __pyx_t_2 = NULL; __pyx_t_5 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_K4Se}; + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_extend_graph_with_Plan}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 285, __pyx_L1_error) + __PYX_ERR(0, 270, __pyx_L1_error) - /* "planarity/full/graph.pyx":284 + /* "planarity/full/graph.pyx":269 * - * def gp_ExtendWith_K4Search(self): - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: # <<<<<<<<<<<<<< - * raise RuntimeError("Failed to extend graph with K4Search structures.") + * def gp_ExtendWith_Planarity(self): + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: # <<<<<<<<<<<<<< + * raise RuntimeError("Failed to extend graph with Planarity structures.") * */ } - /* "planarity/full/graph.pyx":283 - * raise RuntimeError("Failed to extend graph with K33Search structures.") + /* "planarity/full/graph.pyx":268 + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") * - * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K4Search structures.") + * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Planarity structures.") */ /* function exit code */ @@ -9628,7 +9278,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Searc __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_K4Search", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("planarity.full.graph.Graph.gp_ExtendWith_Planarity", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -9636,8 +9286,8 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Searc return __pyx_r; } -/* "planarity/full/graph.pyx":287 - * raise RuntimeError("Failed to extend graph with K4Search structures.") +/* "planarity/full/graph.pyx":272 + * raise RuntimeError("Failed to extend graph with Planarity structures.") * * def gp_Embed(self, int embedFlags) -> int: # <<<<<<<<<<<<<< * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) @@ -9645,16 +9295,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Searc */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_71gp_Embed(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_69gp_Embed(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_70gp_Embed, "Graph.gp_Embed(self, int embedFlags) -> int"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_71gp_Embed = {"gp_Embed", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_71gp_Embed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_70gp_Embed}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_71gp_Embed(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_68gp_Embed, "Graph.gp_Embed(self, int embedFlags) -> int"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_69gp_Embed = {"gp_Embed", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_69gp_Embed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_68gp_Embed}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_69gp_Embed(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -9684,32 +9334,32 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_embedFlags,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 287, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 272, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 287, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 272, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Embed", 0) < (0)) __PYX_ERR(0, 287, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_Embed", 0) < (0)) __PYX_ERR(0, 272, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Embed", 1, 1, 1, i); __PYX_ERR(0, 287, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_Embed", 1, 1, 1, i); __PYX_ERR(0, 272, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 287, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 272, __pyx_L3_error) } - __pyx_v_embedFlags = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_embedFlags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L3_error) + __pyx_v_embedFlags = __Pyx_PyLong_As_int(values[0]); if (unlikely((__pyx_v_embedFlags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 272, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_Embed", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 287, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_Embed", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 272, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -9720,7 +9370,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_embedFlags); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_68gp_Embed(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_embedFlags); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -9730,7 +9380,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_embedFlags) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_68gp_Embed(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, int __pyx_v_embedFlags) { int __pyx_v_embed_result; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -9745,7 +9395,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_Embed", 0); - /* "planarity/full/graph.pyx":288 + /* "planarity/full/graph.pyx":273 * * def gp_Embed(self, int embedFlags) -> int: * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) # <<<<<<<<<<<<<< @@ -9754,41 +9404,41 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx */ __pyx_v_embed_result = gp_Embed(__pyx_v_self->_theGraph, __pyx_v_embedFlags); - /* "planarity/full/graph.pyx":289 + /* "planarity/full/graph.pyx":274 * def gp_Embed(self, int embedFlags) -> int: * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) * if embed_result != OK and embed_result != NONEMBEDDABLE: # <<<<<<<<<<<<<< * raise RuntimeError("Failed to perform embed operation.") * */ - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":290 + /* "planarity/full/graph.pyx":275 * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) * if embed_result != OK and embed_result != NONEMBEDDABLE: * raise RuntimeError("Failed to perform embed operation.") # <<<<<<<<<<<<<< @@ -9801,14 +9451,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Failed_to_perform_embed_operatio}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 290, __pyx_L1_error) + __PYX_ERR(0, 275, __pyx_L1_error) - /* "planarity/full/graph.pyx":289 + /* "planarity/full/graph.pyx":274 * def gp_Embed(self, int embedFlags) -> int: * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) * if embed_result != OK and embed_result != NONEMBEDDABLE: # <<<<<<<<<<<<<< @@ -9817,7 +9467,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx */ } - /* "planarity/full/graph.pyx":292 + /* "planarity/full/graph.pyx":277 * raise RuntimeError("Failed to perform embed operation.") * * return embed_result # <<<<<<<<<<<<<< @@ -9825,15 +9475,15 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx * def gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_embed_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 292, __pyx_L1_error) + if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 277, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":287 - * raise RuntimeError("Failed to extend graph with K4Search structures.") + /* "planarity/full/graph.pyx":272 + * raise RuntimeError("Failed to extend graph with Planarity structures.") * * def gp_Embed(self, int embedFlags) -> int: # <<<<<<<<<<<<<< * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) @@ -9853,7 +9503,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx return __pyx_r; } -/* "planarity/full/graph.pyx":294 +/* "planarity/full/graph.pyx":279 * return embed_result * * def gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int: # <<<<<<<<<<<<<< @@ -9862,16 +9512,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_Embed(struct __pyx */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity, "Graph.gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity = {"gp_TestEmbedResultIntegrity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity, "Graph.gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity = {"gp_TestEmbedResultIntegrity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -9902,39 +9552,39 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_copy_of_orig_graph,&__pyx_mstate_global->__pyx_n_u_embed_result,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 294, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 279, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 294, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 279, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 294, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 279, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_TestEmbedResultIntegrity", 0) < (0)) __PYX_ERR(0, 294, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "gp_TestEmbedResultIntegrity", 0) < (0)) __PYX_ERR(0, 279, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_TestEmbedResultIntegrity", 1, 2, 2, i); __PYX_ERR(0, 294, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("gp_TestEmbedResultIntegrity", 1, 2, 2, i); __PYX_ERR(0, 279, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 294, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 279, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 294, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 279, __pyx_L3_error) } __pyx_v_copy_of_orig_graph = ((struct __pyx_obj_9planarity_4full_5graph_Graph *)values[0]); - __pyx_v_embed_result = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_embed_result == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 294, __pyx_L3_error) + __pyx_v_embed_result = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_embed_result == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gp_TestEmbedResultIntegrity", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 294, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("gp_TestEmbedResultIntegrity", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 279, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -9945,8 +9595,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_copy_of_orig_graph), __pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, 1, "copy_of_orig_graph", 0))) __PYX_ERR(0, 294, __pyx_L1_error) - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_copy_of_orig_graph, __pyx_v_embed_result); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_copy_of_orig_graph), __pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, 1, "copy_of_orig_graph", 0))) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v_copy_of_orig_graph, __pyx_v_embed_result); /* function exit code */ goto __pyx_L0; @@ -9965,7 +9615,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_copy_of_orig_graph, int __pyx_v_embed_result) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity(struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_copy_of_orig_graph, int __pyx_v_embed_result) { int __pyx_v_check_result; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -9980,7 +9630,7 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultInt int __pyx_clineno = 0; __Pyx_RefNannySetupContext("gp_TestEmbedResultIntegrity", 0); - /* "planarity/full/graph.pyx":295 + /* "planarity/full/graph.pyx":280 * * def gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int: * check_result = cgraphLib.gp_TestEmbedResultIntegrity( # <<<<<<<<<<<<<< @@ -9989,41 +9639,41 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultInt */ __pyx_v_check_result = gp_TestEmbedResultIntegrity(__pyx_v_self->_theGraph, __pyx_v_copy_of_orig_graph->_theGraph, __pyx_v_embed_result); - /* "planarity/full/graph.pyx":298 + /* "planarity/full/graph.pyx":283 * self._theGraph, copy_of_orig_graph._theGraph, embed_result * ) * if check_result != OK and check_result != NONEMBEDDABLE: # <<<<<<<<<<<<<< * raise RuntimeError("Failed embed integrity check.") * */ - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } - __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { - /* "planarity/full/graph.pyx":299 + /* "planarity/full/graph.pyx":284 * ) * if check_result != OK and check_result != NONEMBEDDABLE: * raise RuntimeError("Failed embed integrity check.") # <<<<<<<<<<<<<< @@ -10036,14 +9686,14 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultInt PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Failed_embed_integrity_check}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 299, __pyx_L1_error) + __PYX_ERR(0, 284, __pyx_L1_error) - /* "planarity/full/graph.pyx":298 + /* "planarity/full/graph.pyx":283 * self._theGraph, copy_of_orig_graph._theGraph, embed_result * ) * if check_result != OK and check_result != NONEMBEDDABLE: # <<<<<<<<<<<<<< @@ -10052,20 +9702,22 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultInt */ } - /* "planarity/full/graph.pyx":301 + /* "planarity/full/graph.pyx":286 * raise RuntimeError("Failed embed integrity check.") * * return check_result # <<<<<<<<<<<<<< + * + * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_check_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 301, __pyx_L1_error) + if (__Pyx_PyInt_FromNumber(&__pyx_t_2, NULL, 0) < (0)) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "planarity/full/graph.pyx":294 + /* "planarity/full/graph.pyx":279 * return embed_result * * def gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int: # <<<<<<<<<<<<<< @@ -10093,16 +9745,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultInt */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_75__reduce_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_73__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_74__reduce_cython__, "Graph.__reduce_cython__(self)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_75__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_75__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_74__reduce_cython__}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_75__reduce_cython__(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_72__reduce_cython__, "Graph.__reduce_cython__(self)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_73__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_73__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_72__reduce_cython__}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_73__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -10128,14 +9780,14 @@ PyObject *__pyx_args, PyObject *__pyx_kwds const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_74__reduce_cython__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_72__reduce_cython__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_74__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_72__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; @@ -10175,16 +9827,16 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_74__reduce_cython__(CYT */ /* Python wrapper */ -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_77__setstate_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_75__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_76__setstate_cython__, "Graph.__setstate_cython__(self, __pyx_state)"); -static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_77__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_77__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_76__setstate_cython__}; -static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_77__setstate_cython__(PyObject *__pyx_v_self, +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_5Graph_74__setstate_cython__, "Graph.__setstate_cython__(self, __pyx_state)"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_5Graph_75__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_75__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_74__setstate_cython__}; +static PyObject *__pyx_pw_9planarity_4full_5graph_5Graph_75__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -10250,7 +9902,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_76__setstate_cython__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v___pyx_state); + __pyx_r = __pyx_pf_9planarity_4full_5graph_5Graph_74__setstate_cython__(((struct __pyx_obj_9planarity_4full_5graph_Graph *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -10260,7 +9912,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_76__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_74__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9planarity_4full_5graph_Graph *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; @@ -10291,6 +9943,165 @@ static PyObject *__pyx_pf_9planarity_4full_5graph_5Graph_76__setstate_cython__(C __Pyx_RefNannyFinishContext(); return __pyx_r; } + +/* "planarity/full/graph.pyx":289 + * + * + * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() + * return encoded_version.decode('utf-8') +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_gp_GetProjectVersionFull, "gp_GetProjectVersionFull()"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_1gp_GetProjectVersionFull = {"gp_GetProjectVersionFull", (PyCFunction)__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull, METH_NOARGS, __pyx_doc_9planarity_4full_5graph_gp_GetProjectVersionFull}; +static PyObject *__pyx_pw_9planarity_4full_5graph_1gp_GetProjectVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_GetProjectVersionFull (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_gp_GetProjectVersionFull(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_v_encoded_version = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_GetProjectVersionFull", 0); + + /* "planarity/full/graph.pyx":290 + * + * def gp_GetProjectVersionFull(): + * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() # <<<<<<<<<<<<<< + * return encoded_version.decode('utf-8') + * +*/ + __pyx_t_1 = __Pyx_PyBytes_FromString(gp_GetProjectVersionFull()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_encoded_version = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "planarity/full/graph.pyx":291 + * def gp_GetProjectVersionFull(): + * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() + * return encoded_version.decode('utf-8') # <<<<<<<<<<<<<< + * + * +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_encoded_version, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "planarity/full/graph.pyx":289 + * + * + * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() + * return encoded_version.decode('utf-8') +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.gp_GetProjectVersionFull", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_encoded_version); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "planarity/full/graph.pyx":294 + * + * + * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() + * return encoded_version.decode('utf-8') +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +PyDoc_STRVAR(__pyx_doc_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull, "gp_GetLibPlanarityVersionFull()"); +static PyMethodDef __pyx_mdef_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull = {"gp_GetLibPlanarityVersionFull", (PyCFunction)__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull, METH_NOARGS, __pyx_doc_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull}; +static PyObject *__pyx_pw_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("gp_GetLibPlanarityVersionFull (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_9planarity_4full_5graph_2gp_GetLibPlanarityVersionFull(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_v_encoded_version = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("gp_GetLibPlanarityVersionFull", 0); + + /* "planarity/full/graph.pyx":295 + * + * def gp_GetLibPlanarityVersionFull(): + * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() # <<<<<<<<<<<<<< + * return encoded_version.decode('utf-8') +*/ + __pyx_t_1 = __Pyx_PyBytes_FromString(gp_GetLibPlanarityVersionFull()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_encoded_version = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "planarity/full/graph.pyx":296 + * def gp_GetLibPlanarityVersionFull(): + * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() + * return encoded_version.decode('utf-8') # <<<<<<<<<<<<<< +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_encoded_version, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "planarity/full/graph.pyx":294 + * + * + * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() + * return encoded_version.decode('utf-8') +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("planarity.full.graph.gp_GetLibPlanarityVersionFull", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_encoded_version); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} /* #### Code section: module_exttypes ### */ static PyObject *__pyx_tp_new_9planarity_4full_5graph_Graph(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { @@ -10335,43 +10146,42 @@ static void __pyx_tp_dealloc_9planarity_4full_5graph_Graph(PyObject *o) { } static PyMethodDef __pyx_methods_9planarity_4full_5graph_Graph[] = { - {"gp_IsEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_5gp_IsEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_4gp_IsEdge}, - {"gp_EdgeArrayStart", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_6gp_EdgeArrayStart}, - {"gp_EdgeInUse", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EdgeInUse, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_8gp_EdgeInUse}, - {"gp_EdgeArraySize", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_10gp_EdgeArraySize}, - {"gp_EdgeInUseArraySize", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_12gp_EdgeInUseArraySize}, - {"gp_GetFirstEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_14gp_GetFirstEdge}, - {"gp_GetNextEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_17gp_GetNextEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_16gp_GetNextEdge}, - {"gp_GetNeighbor", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_19gp_GetNeighbor, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_18gp_GetNeighbor}, - {"gp_IsVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_21gp_IsVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_20gp_IsVertex}, - {"gp_GetFirstVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_22gp_GetFirstVertex}, - {"gp_GetLastVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_25gp_GetLastVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_24gp_GetLastVertex}, - {"gp_VertexInRangeAscending", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_26gp_VertexInRangeAscending}, - {"gp_GetN", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_29gp_GetN, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_28gp_GetN}, - {"gp_InitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_31gp_InitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_30gp_InitGraph}, - {"gp_ReinitializeGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_32gp_ReinitializeGraph}, - {"gp_CopyGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_35gp_CopyGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_34gp_CopyGraph}, - {"gp_DupGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_37gp_DupGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_36gp_DupGraph}, - {"gp_Read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_39gp_Read, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_38gp_Read}, - {"gp_Write", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_41gp_Write, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_40gp_Write}, - {"gp_FindEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_43gp_FindEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_42gp_FindEdge}, - {"gp_GetVertexDegree", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_44gp_GetVertexDegree}, - {"gp_GetEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_46gp_GetEdgeCapacity}, - {"gp_EnsureEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_48gp_EnsureEdgeCapacity}, - {"gp_AddEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_51gp_AddEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_50gp_AddEdge}, - {"gp_DeleteEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_53gp_DeleteEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_52gp_DeleteEdge}, - {"gp_ExtendWith_Planarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_54gp_ExtendWith_Planarity}, - {"gp_ExtendWith_DrawPlanar", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_56gp_ExtendWith_DrawPlanar}, - {"gp_DrawPlanar_RenderToFile", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_58gp_DrawPlanar_RenderToFile}, - {"gp_DrawPlanar_RenderToString", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToString}, - {"gp_ExtendWith_Outerplanarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_62gp_ExtendWith_Outerplanarity}, - {"gp_ExtendWith_K23Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_K23Search}, - {"gp_ExtendWith_K33Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_K33Search}, - {"gp_ExtendWith_K4Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_68gp_ExtendWith_K4Search}, - {"gp_Embed", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_71gp_Embed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_70gp_Embed}, - {"gp_TestEmbedResultIntegrity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_72gp_TestEmbedResultIntegrity}, - {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_75__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_74__reduce_cython__}, - {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_77__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_76__setstate_cython__}, + {"gp_InitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_5gp_InitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_4gp_InitGraph}, + {"gp_ReinitGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_7gp_ReinitGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_6gp_ReinitGraph}, + {"gp_EnsureEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_8gp_EnsureEdgeCapacity}, + {"gp_GetEdgeCapacity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_10gp_GetEdgeCapacity}, + {"gp_GetN", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_13gp_GetN, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_12gp_GetN}, + {"gp_CopyGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_15gp_CopyGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_14gp_CopyGraph}, + {"gp_DupGraph", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_17gp_DupGraph, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_16gp_DupGraph}, + {"gp_FindEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_19gp_FindEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_18gp_FindEdge}, + {"gp_GetVertexDegree", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_20gp_GetVertexDegree}, + {"gp_AddEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_23gp_AddEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_22gp_AddEdge}, + {"gp_DeleteEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_25gp_DeleteEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_24gp_DeleteEdge}, + {"gp_LowerBoundEdgeStorage", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_26gp_LowerBoundEdgeStorage}, + {"gp_UpperBoundEdgeStorage", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_28gp_UpperBoundEdgeStorage}, + {"gp_IsEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_31gp_IsEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_30gp_IsEdge}, + {"gp_EdgeInUse", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_33gp_EdgeInUse, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_32gp_EdgeInUse}, + {"gp_UpperBoundEdges", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_34gp_UpperBoundEdges}, + {"gp_GetNextEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_37gp_GetNextEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_36gp_GetNextEdge}, + {"gp_GetNeighbor", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_39gp_GetNeighbor, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_38gp_GetNeighbor}, + {"gp_GetFirstEdge", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_40gp_GetFirstEdge}, + {"gp_LowerBoundVertices", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_42gp_LowerBoundVertices}, + {"gp_UpperBoundVertices", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_44gp_UpperBoundVertices}, + {"gp_IsVertex", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_47gp_IsVertex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_46gp_IsVertex}, + {"gp_ExtendWith_K23Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_48gp_ExtendWith_K23Search}, + {"gp_ExtendWith_K33Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_50gp_ExtendWith_K33Search}, + {"gp_ExtendWith_K4Search", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_52gp_ExtendWith_K4Search}, + {"gp_Read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_55gp_Read, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_54gp_Read}, + {"gp_Write", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_57gp_Write, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_56gp_Write}, + {"gp_ExtendWith_DrawPlanar", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_58gp_ExtendWith_DrawPlanar}, + {"gp_DrawPlanar_RenderToFile", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_60gp_DrawPlanar_RenderToFile}, + {"gp_DrawPlanar_RenderToString", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_62gp_DrawPlanar_RenderToString}, + {"gp_ExtendWith_Outerplanarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_64gp_ExtendWith_Outerplanarity}, + {"gp_ExtendWith_Planarity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_66gp_ExtendWith_Planarity}, + {"gp_Embed", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_69gp_Embed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_68gp_Embed}, + {"gp_TestEmbedResultIntegrity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_70gp_TestEmbedResultIntegrity}, + {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_73__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_72__reduce_cython__}, + {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9planarity_4full_5graph_5Graph_75__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9planarity_4full_5graph_5Graph_74__setstate_cython__}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS @@ -10517,15 +10327,15 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ #if CYTHON_USE_TYPE_SPECS - __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9planarity_4full_5graph_Graph_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph)) __PYX_ERR(0, 38, __pyx_L1_error) - if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9planarity_4full_5graph_Graph_spec, __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 38, __pyx_L1_error) + __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9planarity_4full_5graph_Graph_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph)) __PYX_ERR(0, 29, __pyx_L1_error) + if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9planarity_4full_5graph_Graph_spec, __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 29, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph = &__pyx_type_9planarity_4full_5graph_Graph; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS - if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 38, __pyx_L1_error) + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 29, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph); @@ -10535,8 +10345,8 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph->tp_getattro = PyObject_GenericGetAttr; } #endif - if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_Graph, (PyObject *) __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 38, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 38, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_Graph, (PyObject *) __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 29, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_9planarity_4full_5graph_Graph) < (0)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -10842,8 +10652,8 @@ __Pyx_RefNannySetupContext("PyInit_graph", 0); * from planarity.full cimport cgraphLib * * OK = cappconst.OK # <<<<<<<<<<<<<< + * AT_EDGE_CAPACITY_LIMIT = cgraphLib.AT_EDGE_CAPACITY_LIMIT * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE - * NOTOK = cappconst.NOTOK */ __pyx_t_2 = __Pyx_PyLong_From_int(OK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -10853,684 +10663,651 @@ __Pyx_RefNannySetupContext("PyInit_graph", 0); /* "planarity/full/graph.pyx":16 * * OK = cappconst.OK - * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE # <<<<<<<<<<<<<< + * AT_EDGE_CAPACITY_LIMIT = cgraphLib.AT_EDGE_CAPACITY_LIMIT # <<<<<<<<<<<<<< + * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE * NOTOK = cappconst.NOTOK - * NIL = cappconst.NIL */ - __pyx_t_2 = __Pyx_PyLong_From_int(NONEMBEDDABLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(AT_EDGE_CAPACITY_LIMIT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE, __pyx_t_2) < (0)) __PYX_ERR(0, 16, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_AT_EDGE_CAPACITY_LIMIT, __pyx_t_2) < (0)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "planarity/full/graph.pyx":17 * OK = cappconst.OK + * AT_EDGE_CAPACITY_LIMIT = cgraphLib.AT_EDGE_CAPACITY_LIMIT + * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE # <<<<<<<<<<<<<< + * NOTOK = cappconst.NOTOK + * NIL = cappconst.NIL +*/ + __pyx_t_2 = __Pyx_PyLong_From_int(NONEMBEDDABLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NONEMBEDDABLE, __pyx_t_2) < (0)) __PYX_ERR(0, 17, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "planarity/full/graph.pyx":18 + * AT_EDGE_CAPACITY_LIMIT = cgraphLib.AT_EDGE_CAPACITY_LIMIT * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE * NOTOK = cappconst.NOTOK # <<<<<<<<<<<<<< * NIL = cappconst.NIL * */ - __pyx_t_2 = __Pyx_PyLong_From_int(NOTOK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(NOTOK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NOTOK, __pyx_t_2) < (0)) __PYX_ERR(0, 17, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NOTOK, __pyx_t_2) < (0)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":18 + /* "planarity/full/graph.pyx":19 * NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE * NOTOK = cappconst.NOTOK * NIL = cappconst.NIL # <<<<<<<<<<<<<< * * EMBEDFLAGS_PLANAR = cgraphLib.EMBEDFLAGS_PLANAR */ - __pyx_t_2 = __Pyx_PyLong_From_int(NIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(NIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NIL, __pyx_t_2) < (0)) __PYX_ERR(0, 18, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NIL, __pyx_t_2) < (0)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":20 + /* "planarity/full/graph.pyx":21 * NIL = cappconst.NIL * * EMBEDFLAGS_PLANAR = cgraphLib.EMBEDFLAGS_PLANAR # <<<<<<<<<<<<<< * EMBEDFLAGS_DRAWPLANAR = cgraphLib.EMBEDFLAGS_DRAWPLANAR * EMBEDFLAGS_OUTERPLANAR = cgraphLib.EMBEDFLAGS_OUTERPLANAR */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_PLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_PLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_PLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 20, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_PLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":21 + /* "planarity/full/graph.pyx":22 * * EMBEDFLAGS_PLANAR = cgraphLib.EMBEDFLAGS_PLANAR * EMBEDFLAGS_DRAWPLANAR = cgraphLib.EMBEDFLAGS_DRAWPLANAR # <<<<<<<<<<<<<< * EMBEDFLAGS_OUTERPLANAR = cgraphLib.EMBEDFLAGS_OUTERPLANAR * EMBEDFLAGS_SEARCHFORK23 = cgraphLib.EMBEDFLAGS_SEARCHFORK23 */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_DRAWPLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_DRAWPLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_DRAWPLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 21, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_DRAWPLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":22 + /* "planarity/full/graph.pyx":23 * EMBEDFLAGS_PLANAR = cgraphLib.EMBEDFLAGS_PLANAR * EMBEDFLAGS_DRAWPLANAR = cgraphLib.EMBEDFLAGS_DRAWPLANAR * EMBEDFLAGS_OUTERPLANAR = cgraphLib.EMBEDFLAGS_OUTERPLANAR # <<<<<<<<<<<<<< * EMBEDFLAGS_SEARCHFORK23 = cgraphLib.EMBEDFLAGS_SEARCHFORK23 * EMBEDFLAGS_SEARCHFORK33 = cgraphLib.EMBEDFLAGS_SEARCHFORK33 */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_OUTERPLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_OUTERPLANAR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_OUTERPLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 22, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_OUTERPLANAR, __pyx_t_2) < (0)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":23 + /* "planarity/full/graph.pyx":24 * EMBEDFLAGS_DRAWPLANAR = cgraphLib.EMBEDFLAGS_DRAWPLANAR * EMBEDFLAGS_OUTERPLANAR = cgraphLib.EMBEDFLAGS_OUTERPLANAR * EMBEDFLAGS_SEARCHFORK23 = cgraphLib.EMBEDFLAGS_SEARCHFORK23 # <<<<<<<<<<<<<< * EMBEDFLAGS_SEARCHFORK33 = cgraphLib.EMBEDFLAGS_SEARCHFORK33 * EMBEDFLAGS_SEARCHFORK4 = cgraphLib.EMBEDFLAGS_SEARCHFORK4 */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK23); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK23); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK23, __pyx_t_2) < (0)) __PYX_ERR(0, 23, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK23, __pyx_t_2) < (0)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":24 + /* "planarity/full/graph.pyx":25 * EMBEDFLAGS_OUTERPLANAR = cgraphLib.EMBEDFLAGS_OUTERPLANAR * EMBEDFLAGS_SEARCHFORK23 = cgraphLib.EMBEDFLAGS_SEARCHFORK23 * EMBEDFLAGS_SEARCHFORK33 = cgraphLib.EMBEDFLAGS_SEARCHFORK33 # <<<<<<<<<<<<<< * EMBEDFLAGS_SEARCHFORK4 = cgraphLib.EMBEDFLAGS_SEARCHFORK4 * */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK33); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK33); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK33, __pyx_t_2) < (0)) __PYX_ERR(0, 24, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK33, __pyx_t_2) < (0)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":25 + /* "planarity/full/graph.pyx":26 * EMBEDFLAGS_SEARCHFORK23 = cgraphLib.EMBEDFLAGS_SEARCHFORK23 * EMBEDFLAGS_SEARCHFORK33 = cgraphLib.EMBEDFLAGS_SEARCHFORK33 * EMBEDFLAGS_SEARCHFORK4 = cgraphLib.EMBEDFLAGS_SEARCHFORK4 # <<<<<<<<<<<<<< * * */ - __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_int(EMBEDFLAGS_SEARCHFORK4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK4, __pyx_t_2) < (0)) __PYX_ERR(0, 25, __pyx_L1_error) + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EMBEDFLAGS_SEARCHFORK4, __pyx_t_2) < (0)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":28 - * - * - * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() - * return encoded_version.decode('utf-8') + /* "planarity/full/graph.pyx":40 + * cgraphLib.gp_Free(&self._theGraph) + * + * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< + * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: + * raise RuntimeError(f"gp_InitGraph() failed.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_1gp_GetProjectVersionFull, 0, __pyx_mstate_global->__pyx_n_u_gp_GetProjectVersionFull, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_5gp_InitGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_InitGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_gp_GetProjectVersionFull, __pyx_t_2) < (0)) __PYX_ERR(0, 28, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_InitGraph, __pyx_t_2) < (0)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":33 + /* "planarity/full/graph.pyx":44 + * raise RuntimeError(f"gp_InitGraph() failed.") * + * def gp_ReinitGraph(self): # <<<<<<<<<<<<<< + * cgraphLib.gp_ReinitGraph(self._theGraph) * - * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< - * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() - * return encoded_version.decode('utf-8') */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull, 0, __pyx_mstate_global->__pyx_n_u_gp_GetLibPlanarityVersionFull, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_7gp_ReinitGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ReinitGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_gp_GetLibPlanarityVersionFull, __pyx_t_2) < (0)) __PYX_ERR(0, 33, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ReinitGraph, __pyx_t_2) < (0)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":49 - * cgraphLib.gp_Free(&self._theGraph) + /* "planarity/full/graph.pyx":47 + * cgraphLib.gp_ReinitGraph(self._theGraph) * - * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< - * return ( - * (e >= self.gp_EdgeArrayStart()) and + * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< + * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_5gp_IsEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_IsEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_9gp_EnsureEdgeCapacity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EnsureEdgeCapacity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 49, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EnsureEdgeCapacity, __pyx_t_2) < (0)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":56 - * ) + /* "planarity/full/graph.pyx":53 + * f"{new_edge_capacity}.") * - * def gp_EdgeArrayStart(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) + * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_7gp_EdgeArrayStart, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EdgeArrayStart, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_11gp_GetEdgeCapacity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetEdgeCapacity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EdgeArrayStart, __pyx_t_2) < (0)) __PYX_ERR(0, 56, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetEdgeCapacity, __pyx_t_2) < (0)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":59 - * return cgraphLib.gp_EdgeArrayStart(self._theGraph) + /* "planarity/full/graph.pyx":56 + * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) * - * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< + * """ + * Returns the number of vertices in the graph. */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_9gp_EdgeInUse, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EdgeInUse, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 56, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_13gp_GetN, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetN, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EdgeInUse, __pyx_t_2) < (0)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_t_3) < (0)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "planarity/full/graph.pyx":67 - * return cgraphLib.gp_EdgeInUse(self._theGraph, e) - * - * def gp_EdgeArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeArraySize(self._theGraph) + /* "planarity/full/graph.pyx":65 + * return cgraphLib.gp_GetN(self._theGraph) * + * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< + * # NOTE: this is interpreting the self as the dstGraph, i.e. copying + * # the Graph wrapper that is passed in as the srcGraph */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_11gp_EdgeArraySize, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EdgeArraySize, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_15gp_CopyGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_CopyGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EdgeArraySize, __pyx_t_2) < (0)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_CopyGraph, __pyx_t_3) < (0)) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "planarity/full/graph.pyx":70 - * return cgraphLib.gp_EdgeArraySize(self._theGraph) - * - * def gp_EdgeInUseArraySize(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) + /* "planarity/full/graph.pyx":89 + * raise RuntimeError(f"gp_CopyGraph() failed.") * + * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< + * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) + * if theGraph_dup == NULL: */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_13gp_EdgeInUseArraySize, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EdgeInUseArraySize, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_Graph) < (0)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_17gp_DupGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DupGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EdgeInUseArraySize, __pyx_t_2) < (0)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DupGraph, __pyx_t_2) < (0)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":73 - * return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) + /* "planarity/full/graph.pyx":100 + * return new_graph * - * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError( + * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(u): + * raise RuntimeError(f"'{u}' is not a valid vertex label.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_15gp_GetFirstEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetFirstEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_19gp_FindEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_FindEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetFirstEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 73, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_FindEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":81 - * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + /* "planarity/full/graph.pyx":108 + * return cgraphLib.gp_FindEdge(self._theGraph, u, v) * - * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError(f"'{v}' is not a valid vertex label.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_17gp_GetNextEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetNextEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_21gp_GetVertexDegree, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetVertexDegree, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetNextEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 81, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetVertexDegree, __pyx_t_2) < (0)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":89 - * return cgraphLib.gp_GetNextEdge(self._theGraph, e) + /* "planarity/full/graph.pyx":114 + * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) * - * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): + * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< + * if ulink != 0 and ulink != 1: * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_19gp_GetNeighbor, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetNeighbor, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_23gp_AddEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_AddEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetNeighbor, __pyx_t_2) < (0)) __PYX_ERR(0, 89, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_AddEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":97 - * return cgraphLib.gp_GetNeighbor(self._theGraph, e) + /* "planarity/full/graph.pyx":129 + * ) * - * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< - * return ( - * (v >= self.gp_GetFirstVertex()) and + * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_21gp_IsVertex, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_IsVertex, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_25gp_DeleteEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DeleteEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_t_2) < (0)) __PYX_ERR(0, 97, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DeleteEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":104 - * ) + /* "planarity/full/graph.pyx":137 + * return cgraphLib.gp_DeleteEdge(self._theGraph, e) * - * def gp_GetFirstVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetFirstVertex(self._theGraph) + * def gp_LowerBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) * */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_23gp_GetFirstVertex, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetFirstVertex, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_27gp_LowerBoundEdgeStorage, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_LowerBoundEdgeStorage, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetFirstVertex, __pyx_t_2) < (0)) __PYX_ERR(0, 104, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_LowerBoundEdgeStorage, __pyx_t_2) < (0)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":107 - * return cgraphLib.gp_GetFirstVertex(self._theGraph) + /* "planarity/full/graph.pyx":140 + * return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) * - * def gp_GetLastVertex(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetLastVertex(self._theGraph) + * def gp_UpperBoundEdgeStorage(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) * */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_25gp_GetLastVertex, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetLastVertex, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_29gp_UpperBoundEdgeStorage, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_UpperBoundEdgeStorage, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetLastVertex, __pyx_t_2) < (0)) __PYX_ERR(0, 107, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_UpperBoundEdgeStorage, __pyx_t_2) < (0)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":110 - * return cgraphLib.gp_GetLastVertex(self._theGraph) + /* "planarity/full/graph.pyx":143 + * return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) * - * def gp_VertexInRangeAscending(self, int v): # <<<<<<<<<<<<<< + * def gp_IsEdge(self, int e): # <<<<<<<<<<<<<< * return ( - * v >= self.gp_GetFirstVertex() and + * (e >= self.gp_LowerBoundEdgeStorage()) and */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_27gp_VertexInRangeAscending, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_VertexInRangeAscending, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_31gp_IsEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_IsEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_VertexInRangeAscending, __pyx_t_2) < (0)) __PYX_ERR(0, 110, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_IsEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":116 + /* "planarity/full/graph.pyx":150 * ) * - * def gp_GetN(self)-> int: # <<<<<<<<<<<<<< - * """ - * Returns the number of vertices in the graph. + * def gp_EdgeInUse(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_33gp_EdgeInUse, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EdgeInUse, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 116, __pyx_L1_error) - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_29gp_GetN, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetN, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_2); + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EdgeInUse, __pyx_t_2) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetN, __pyx_t_3) < (0)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "planarity/full/graph.pyx":125 - * return cgraphLib.gp_GetN(self._theGraph) - * - * def gp_InitGraph(self, int n): # <<<<<<<<<<<<<< - * if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: - * raise RuntimeError(f"gp_InitGraph() failed.") -*/ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_31gp_InitGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_InitGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[15])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); - #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_InitGraph, __pyx_t_3) < (0)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "planarity/full/graph.pyx":129 - * raise RuntimeError(f"gp_InitGraph() failed.") - * - * def gp_ReinitializeGraph(self): # <<<<<<<<<<<<<< - * cgraphLib.gp_ReinitializeGraph(self._theGraph) - * -*/ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_33gp_ReinitializeGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ReinitializeGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); - #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ReinitializeGraph, __pyx_t_3) < (0)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "planarity/full/graph.pyx":132 - * cgraphLib.gp_ReinitializeGraph(self._theGraph) + /* "planarity/full/graph.pyx":158 + * return cgraphLib.gp_EdgeInUse(self._theGraph, e) * - * def gp_CopyGraph(self, Graph src_graph): # <<<<<<<<<<<<<< - * # NOTE: this is interpreting the self as the dstGraph, i.e. copying - * # the Graph wrapper that is passed in as the srcGraph -*/ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_35gp_CopyGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_CopyGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); - #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_CopyGraph, __pyx_t_3) < (0)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "planarity/full/graph.pyx":156 - * raise RuntimeError(f"gp_CopyGraph() failed.") + * def gp_UpperBoundEdges(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_DupGraph(self) -> Graph: # <<<<<<<<<<<<<< - * cdef cgraphLib.graphP theGraph_dup = cgraphLib.gp_DupGraph(self._theGraph) - * if theGraph_dup == NULL: */ - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_Graph) < (0)) __PYX_ERR(0, 156, __pyx_L1_error) - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_37gp_DupGraph, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DupGraph, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[18])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_35gp_UpperBoundEdges, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_UpperBoundEdges, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[15])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DupGraph, __pyx_t_2) < (0)) __PYX_ERR(0, 156, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_UpperBoundEdges, __pyx_t_2) < (0)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":167 - * return new_graph + /* "planarity/full/graph.pyx":161 + * return cgraphLib.gp_UpperBoundEdges(self._theGraph) * - * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = infile_name.encode('utf-8') + * def gp_GetNextEdge(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_39gp_Read, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Read, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[19])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_37gp_GetNextEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetNextEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Read, __pyx_t_2) < (0)) __PYX_ERR(0, 167, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetNextEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":175 - * raise RuntimeError(f"gp_Read() failed.") + /* "planarity/full/graph.pyx":169 + * return cgraphLib.gp_GetNextEdge(self._theGraph, e) * - * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< - * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + * def gp_GetNeighbor(self, int e): # <<<<<<<<<<<<<< + * if not self.gp_IsEdge(e): + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_41gp_Write, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Write, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[20])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_39gp_GetNeighbor, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetNeighbor, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Write, __pyx_t_2) < (0)) __PYX_ERR(0, 175, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetNeighbor, __pyx_t_2) < (0)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":195 - * ) + /* "planarity/full/graph.pyx":177 + * return cgraphLib.gp_GetNeighbor(self._theGraph, e) * - * def gp_FindEdge(self, int u, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(u): - * raise RuntimeError(f"'{u}' is not a valid vertex label.") + * def gp_GetFirstEdge(self, int v): # <<<<<<<<<<<<<< + * if not self.gp_IsVertex(v): + * raise RuntimeError( */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_43gp_FindEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_FindEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[21])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_41gp_GetFirstEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetFirstEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[18])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_FindEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 195, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetFirstEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 177, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":203 - * return cgraphLib.gp_FindEdge(self._theGraph, u, v) + /* "planarity/full/graph.pyx":185 + * return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + * + * def gp_LowerBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) * - * def gp_GetVertexDegree(self, int v): # <<<<<<<<<<<<<< - * if not self.gp_IsVertex(v): - * raise RuntimeError(f"'{v}' is not a valid vertex label.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_45gp_GetVertexDegree, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetVertexDegree, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[22])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_43gp_LowerBoundVertices, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_LowerBoundVertices, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[19])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetVertexDegree, __pyx_t_2) < (0)) __PYX_ERR(0, 203, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_LowerBoundVertices, __pyx_t_2) < (0)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":209 - * return cgraphLib.gp_GetVertexDegree(self._theGraph, v) + /* "planarity/full/graph.pyx":188 + * return cgraphLib.gp_LowerBoundVertices(self._theGraph) * - * def gp_GetEdgeCapacity(self): # <<<<<<<<<<<<<< - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) + * def gp_UpperBoundVertices(self): # <<<<<<<<<<<<<< + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) * */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_47gp_GetEdgeCapacity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_GetEdgeCapacity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[23])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_45gp_UpperBoundVertices, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_UpperBoundVertices, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[20])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_GetEdgeCapacity, __pyx_t_2) < (0)) __PYX_ERR(0, 209, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_UpperBoundVertices, __pyx_t_2) < (0)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":212 - * return cgraphLib.gp_GetEdgeCapacity(self._theGraph) + /* "planarity/full/graph.pyx":191 + * return cgraphLib.gp_UpperBoundVertices(self._theGraph) * - * def gp_EnsureEdgeCapacity(self, int new_edge_capacity): # <<<<<<<<<<<<<< - * if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - * raise RuntimeError( + * def gp_IsVertex(self, int v): # <<<<<<<<<<<<<< + * return ( + * (v >= self.gp_LowerBoundVertices()) and */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_49gp_EnsureEdgeCapacity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_EnsureEdgeCapacity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[24])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_47gp_IsVertex, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_IsVertex, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[21])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_EnsureEdgeCapacity, __pyx_t_2) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_IsVertex, __pyx_t_2) < (0)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":218 - * f"{new_edge_capacity}.") + /* "planarity/full/graph.pyx":198 + * ) * - * def gp_AddEdge(self, int u, int ulink, int v, int vlink): # <<<<<<<<<<<<<< - * if ulink != 0 and ulink != 1: - * raise RuntimeError( + * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K23Search structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_51gp_AddEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_AddEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[25])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_49gp_ExtendWith_K23Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K23Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[22])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_AddEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 218, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K23Search, __pyx_t_2) < (0)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":233 - * ) + /* "planarity/full/graph.pyx":202 + * raise RuntimeError("Failed to extend graph with K23Search structures.") * - * def gp_DeleteEdge(self, int e): # <<<<<<<<<<<<<< - * if not self.gp_IsEdge(e): - * raise RuntimeError( + * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K33Search structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_53gp_DeleteEdge, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DeleteEdge, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[26])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_51gp_ExtendWith_K33Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K33Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[23])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DeleteEdge, __pyx_t_2) < (0)) __PYX_ERR(0, 233, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K33Search, __pyx_t_2) < (0)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":241 - * return cgraphLib.gp_DeleteEdge(self._theGraph, e) + /* "planarity/full/graph.pyx":206 + * raise RuntimeError("Failed to extend graph with K33Search structures.") * - * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Planarity structures.") + * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with K4Search structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_55gp_ExtendWith_Planarity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_Planarity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[27])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_53gp_ExtendWith_K4Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K4Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[24])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_Planarity, __pyx_t_2) < (0)) __PYX_ERR(0, 241, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K4Search, __pyx_t_2) < (0)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":245 - * raise RuntimeError("Failed to extend graph with Planarity structures.") + /* "planarity/full/graph.pyx":210 + * raise RuntimeError("Failed to extend graph with K4Search structures.") * - * def gp_ExtendWith_DrawPlanar(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") + * def gp_Read(self, str infile_name): # <<<<<<<<<<<<<< + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = infile_name.encode('utf-8') */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_57gp_ExtendWith_DrawPlanar, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_DrawPlanar, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[28])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_55gp_Read, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Read, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[25])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_DrawPlanar, __pyx_t_2) < (0)) __PYX_ERR(0, 245, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Read, __pyx_t_2) < (0)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":249 - * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") + /* "planarity/full/graph.pyx":218 + * raise RuntimeError(f"gp_Read() failed.") * - * def gp_DrawPlanar_RenderToFile(self, str outfile_name): # <<<<<<<<<<<<<< - * # Convert Python str to UTF-8 encoded bytes, and then to const char * - * cdef bytes encoded = outfile_name.encode('utf-8') + * def gp_Write(self, str outfile_name, str mode): # <<<<<<<<<<<<<< + * mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + * else (cgraphLib.WRITE_ADJMATRIX if mode == "m" */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_59gp_DrawPlanar_RenderToFile, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DrawPlanar_RenderToFile, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[29])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_57gp_Write, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Write, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[26])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DrawPlanar_RenderToFile, __pyx_t_2) < (0)) __PYX_ERR(0, 249, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Write, __pyx_t_2) < (0)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":257 - * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") + /* "planarity/full/graph.pyx":238 + * ) * - * def gp_DrawPlanar_RenderToString(self): # <<<<<<<<<<<<<< - * cdef char* renditionString = NULL - * if cgraphLib.gp_DrawPlanar_RenderToString(self._theGraph, &renditionString) != OK: + * def gp_ExtendWith_DrawPlanar(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToString, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DrawPlanar_RenderToStri, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[30])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_59gp_ExtendWith_DrawPlanar, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_DrawPlanar, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[27])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DrawPlanar_RenderToString, __pyx_t_2) < (0)) __PYX_ERR(0, 257, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_DrawPlanar, __pyx_t_2) < (0)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":271 - * free(renditionString) - * - * def gp_ExtendWith_Outerplanarity(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") + /* "planarity/full/graph.pyx":242 + * raise RuntimeError("Failed to extend graph with DrawPlanar structures.") + * + * def gp_DrawPlanar_RenderToFile(self, str outfile_name): # <<<<<<<<<<<<<< + * # Convert Python str to UTF-8 encoded bytes, and then to const char * + * cdef bytes encoded = outfile_name.encode('utf-8') */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_63gp_ExtendWith_Outerplanarity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_Outerplanari, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[31])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_61gp_DrawPlanar_RenderToFile, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DrawPlanar_RenderToFile, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[28])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_Outerplanarity, __pyx_t_2) < (0)) __PYX_ERR(0, 271, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DrawPlanar_RenderToFile, __pyx_t_2) < (0)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":275 - * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") + /* "planarity/full/graph.pyx":250 + * raise RuntimeError(f"Failed to render embedding to file '{outfile_name}'.") * - * def gp_ExtendWith_K23Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K23Search structures.") + * def gp_DrawPlanar_RenderToString(self): # <<<<<<<<<<<<<< + * cdef char* renditionString = NULL + * if cgraphLib.gp_DrawPlanar_RenderToString(self._theGraph, &renditionString) != OK: */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_65gp_ExtendWith_K23Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K23Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[32])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_63gp_DrawPlanar_RenderToString, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_DrawPlanar_RenderToStri, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[29])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K23Search, __pyx_t_2) < (0)) __PYX_ERR(0, 275, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_DrawPlanar_RenderToString, __pyx_t_2) < (0)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":279 - * raise RuntimeError("Failed to extend graph with K23Search structures.") + /* "planarity/full/graph.pyx":264 + * free(renditionString) * - * def gp_ExtendWith_K33Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K33Search structures.") + * def gp_ExtendWith_Outerplanarity(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_67gp_ExtendWith_K33Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K33Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[33])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_65gp_ExtendWith_Outerplanarity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_Outerplanari, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[30])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K33Search, __pyx_t_2) < (0)) __PYX_ERR(0, 279, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_Outerplanarity, __pyx_t_2) < (0)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":283 - * raise RuntimeError("Failed to extend graph with K33Search structures.") + /* "planarity/full/graph.pyx":268 + * raise RuntimeError("Failed to extend graph with Outerplanarity structures.") * - * def gp_ExtendWith_K4Search(self): # <<<<<<<<<<<<<< - * if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: - * raise RuntimeError("Failed to extend graph with K4Search structures.") + * def gp_ExtendWith_Planarity(self): # <<<<<<<<<<<<<< + * if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: + * raise RuntimeError("Failed to extend graph with Planarity structures.") */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_69gp_ExtendWith_K4Search, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_K4Search, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[34])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_67gp_ExtendWith_Planarity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_ExtendWith_Planarity, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[31])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_K4Search, __pyx_t_2) < (0)) __PYX_ERR(0, 283, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_ExtendWith_Planarity, __pyx_t_2) < (0)) __PYX_ERR(0, 268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "planarity/full/graph.pyx":287 - * raise RuntimeError("Failed to extend graph with K4Search structures.") + /* "planarity/full/graph.pyx":272 + * raise RuntimeError("Failed to extend graph with Planarity structures.") * * def gp_Embed(self, int embedFlags) -> int: # <<<<<<<<<<<<<< * embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) * if embed_result != OK and embed_result != NONEMBEDDABLE: */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 287, __pyx_L1_error) - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_71gp_Embed, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Embed, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[35])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 272, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_69gp_Embed, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_Embed, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[32])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); #endif __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Embed, __pyx_t_3) < (0)) __PYX_ERR(0, 287, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_Embed, __pyx_t_3) < (0)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "planarity/full/graph.pyx":294 + /* "planarity/full/graph.pyx":279 * return embed_result * * def gp_TestEmbedResultIntegrity(self, Graph copy_of_orig_graph, int embed_result) -> int: # <<<<<<<<<<<<<< * check_result = cgraphLib.gp_TestEmbedResultIntegrity( * self._theGraph, copy_of_orig_graph._theGraph, embed_result */ - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 294, __pyx_L1_error) - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_73gp_TestEmbedResultIntegrity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_TestEmbedResultIntegrit, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[36])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_71gp_TestEmbedResultIntegrity, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph_gp_TestEmbedResultIntegrit, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[33])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_TestEmbedResultIntegrity, __pyx_t_2) < (0)) __PYX_ERR(0, 294, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_9planarity_4full_5graph_Graph, __pyx_mstate_global->__pyx_n_u_gp_TestEmbedResultIntegrity, __pyx_t_2) < (0)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 @@ -11538,7 +11315,7 @@ __Pyx_RefNannySetupContext("PyInit_graph", 0); * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_75__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[37])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_73__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[34])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); @@ -11552,7 +11329,7 @@ __Pyx_RefNannySetupContext("PyInit_graph", 0); * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_77__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[38])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_5Graph_75__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Graph___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[35])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); @@ -11560,6 +11337,36 @@ __Pyx_RefNannySetupContext("PyInit_graph", 0); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + /* "planarity/full/graph.pyx":289 + * + * + * def gp_GetProjectVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() + * return encoded_version.decode('utf-8') +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_1gp_GetProjectVersionFull, 0, __pyx_mstate_global->__pyx_n_u_gp_GetProjectVersionFull, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[36])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_gp_GetProjectVersionFull, __pyx_t_2) < (0)) __PYX_ERR(0, 289, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "planarity/full/graph.pyx":294 + * + * + * def gp_GetLibPlanarityVersionFull(): # <<<<<<<<<<<<<< + * cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() + * return encoded_version.decode('utf-8') +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9planarity_4full_5graph_3gp_GetLibPlanarityVersionFull, 0, __pyx_mstate_global->__pyx_n_u_gp_GetLibPlanarityVersionFull, NULL, __pyx_mstate_global->__pyx_n_u_planarity_full_graph, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[37])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_gp_GetLibPlanarityVersionFull, __pyx_t_2) < (0)) __PYX_ERR(0, 294, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + /* "planarity/full/graph.pyx":1 * #!/usr/bin/env python # <<<<<<<<<<<<<< * # cython: embedsignature=True @@ -11631,39 +11438,39 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { - const struct { const unsigned int length: 8; } index[] = {{2},{29},{44},{50},{49},{49},{48},{54},{49},{34},{39},{36},{25},{50},{32},{31},{31},{45},{4},{179},{77},{38},{29},{1},{1},{2},{1},{8},{13},{7},{6},{9},{2},{22},{38},{21},{43},{55},{48},{45},{45},{22},{16},{17},{24},{30},{22},{9},{50},{24},{14},{15},{21},{22},{17},{23},{23},{22},{8},{5},{23},{25},{16},{18},{19},{32},{34},{17},{22},{23},{18},{27},{14},{27},{30},{29},{29},{28},{34},{29},{17},{24},{21},{23},{22},{13},{20},{20},{24},{18},{15},{17},{13},{26},{33},{31},{14},{3},{13},{5},{2},{20},{1},{18},{12},{18},{18},{1},{10},{12},{7},{15},{8},{1},{12},{10},{12},{13},{26},{28},{11},{16},{17},{12},{21},{8},{21},{24},{23},{23},{22},{28},{23},{11},{18},{15},{17},{16},{29},{7},{14},{14},{24},{18},{12},{9},{11},{7},{20},{27},{25},{8},{11},{3},{13},{5},{1},{8},{4},{9},{10},{1},{8},{17},{9},{12},{20},{3},{11},{12},{10},{17},{13},{15},{6},{4},{12},{10},{12},{19},{9},{22},{23},{8},{11},{12},{1},{5},{1},{6},{5},{38},{14},{27},{27},{39},{130},{14},{44},{44},{44},{45},{42},{69},{117},{27},{28},{80},{27},{114},{14},{14},{11},{30},{44},{51},{44},{44},{21},{21},{9},{64},{57},{49}}; - #if (CYTHON_COMPRESS_STRINGS) == 3 && __PYX_LIMITED_VERSION_HEX >= 0x030e0000 /* compression: zstd (2166 bytes) */ -const char* const cstring = "(\265/\375`\211\023eC\000\032X\234\022:\000\231\033\374\377\367\372U\247\376u\354W\035_\243\216\257Q\247\376\325\345CdJ\314n2?\265\226+e\t\246\243&U\220*\351\350\204\351\362\n^\2417\345V\330P \303l#\000\001\025\001 \001\245\306e\231\315\\\346?\\\353\\\320\327u\331O\254{\331k`\346\341\357\321\036\366<\343^\332\233Y\246\201\273\357\022\273\306\177r\236]\370k\217\271\346}\2375\307\350\031\304:\035\374\362\332\027\374\230\357on4\207u'\366\332\373l\2229\324c\377I}\244;.y\306)-)$\265X\r\363\256?\271M\235\333\246.3\357c\375O\232\346'M\223\035==\320\205_P\254\2641\022\337\246\306\326mR\373<\376y6\373\241\325\264/\t\277\360\375\275.q\t\344:\257R/m3\357\277\371\306\377\344\330o\034\027\326\225]w~\356\237\317^?u]\373j\276\256?\332\223\202\302#{\3268\224\223\035\257;\372I\264g\236\315ZR\3567\230\367w\022\346\371r\337\341\222\353\257\244\371\311\373\301\332\216\357\376=\266\301\277k ?I|~$R\363H\034\374\273\357\364\347;\327\323\270\324\346\316\262\227+\347\250;G$2\3474\231\373\037\371\036M\262\217^\363\375\321\263\237\344\353\334$\017\372\234u\3726~r\337(\005k\343\270\323\263\323\343\323C\213\315j\304\033Z\017m\246C+\271&=\3177\256\243\363M\324\353\333\367\332\307\353\276\3237J\264<\003\342[VKA\t\372=\177\\0\367.\342N\237\333X\226\342\317\337\177\355\307\221|\351^\246is\313RPn=\262\034\233\233\030\303\335b>?=7\221&\316jA\342\355f\304\341\2103\331M\254\206'\206\202\314\304(\005}\257\022\323Du%\343H\232y\003w\377$\034-\3618j\022-u\037G\374M4\353t\211O^\372\375r\365\262\306\313\324\271l\342\354r\351\316\277{P\231\365-I\323\376\346:J\375\314\361v[\323\276\222\376\276o\331\3278$\231}\331\246\243\236\273\374\017\327\361\241\256\215_b\372kS\337\200|\330\214\276\035\271{\351\260K\373]\2164x\344\345\372\3002\030\004\210G\320\017\254w\001,\241\021\013\301\252\330\017\212\027\346\266\334\032\325\372ScT\302\031+\300\376V\006\225\373\023\322\344v\204-W\333\252\220\2056\241L\033\303\3765\257\013j\205P%l\311\252M}I\177+\312\2731B\220\326\\9V\326\312\223Fd\226\267\016\371T\ta%\005\361 \252!j""\006\303\313\260\032\262\216R\211\025e\r\010B1$\014\017\010\246\304'X\332J\035\032\206\254\206\341\315\366\222Q4\230\267\211Ma[l\210\315\335p\315\226\243e\265\260\237\320F\230\000\361B\250\332\033\026\306\212P\274\024\253\241\370d[!V\325\272R)VR?5\253#\251C\302\320\246n\250LP)P\t\006\000\253)\225J!\360\002\275F\315\014\004\242>\264\0345\357{\375\307\221\373~\366\2569:\222\335\353L\355yG\277\356J\332\314\350\3177\216\276\323\367z\215I\332DG\276so\034{\2767\372=\376^\346\2436\267\216\357\263\327L\023\225\345\366\270\033G\222\243\272\355\273\006\216\245.O\222k\277\313\246L\353q\267{\246\301\332z\226\004\345\004\277\263\024B\030\203_\274\032\022\r\275C\002\357\357\"e\255.jKe\251\025+\252f\254\244D\324\000U\346\347\246\270+\352\205\300kKE\240\016TQ9.\225\006\nA\300&\344\r\021\030\252\236Z\255\210\241K\225Q\256\036]\374\220x9R\017\305\240\220]\233\033\313xk/.JA\350[\"\326b\365QE5G\\9VCU\001[\244^\254\244\334Y\204_]\021/DJB-x\260\332\317f\366\225Y\016\020\030+\212taF\326R\347\267\272ZU;\301\032\251\030\006\000\007Sb\013kQDB\20607\300U\021\366\330W\307Pt\037\334\2300\346\343\375\310\030hM0\336\2414\202\345\222\302\221\266dm,\t+U\245\r\tR\024\023\242\352\004\325bY\254k\245I\037\022\206\006BAo\220\317\353c\363\266lk\307\206\312\305\t-Z\037VdG0\032\262+Sy\305V\240\375\261%?\327\306\r\022n\010Y\332\200v\266\n\354\244\020R-\230\207Z\2465\351C\272\202k-X\237U\\\023TQ\n\266\266V\257\006\201\264\250A%SH\241\221\021\221$I\322\032A\010\002\241\250\203\220\363B\231H\311r\034b\204\031B\210\310\210\214\210\310HRPI\007\324@\225\373\326\227m$k\344\006X\215\347\353Ws.\340%\260s]\\\005y\231\000:\350Y\261\334LQ\022+.\031h|\003Q\330X\230\025WBe\332\364\313M\310\200\207\007\364\201Q#8H\307\350\341\346\006\320\321\341M<\272\021\317O8o\277V\356\316\256<\332+\332 \264\213\224\341\304F\3257\025\253oR\304\271\351\326Ur%N\226h\003\261\0266\256@Kq\342\177\201\203\332\362\377a;d\340\212j\263j\0310\306\311\017;L\341\360DM\244\337+\256\232\r?1\237\232\234\210E\264\200\020I\001s\214V\331y\330?\020\355H""\225fq\327t\\Pt\270\342U\010)\266\337%\3000k\024\376\016\207\250;ae~\243\254\005\036{e\331\355\250\021\214V\374E\212\206\364E\001\002\311\007\2508#\241\210\201\300\215@\275X3\272\307\303{q\334^(h\325/\201\037jG\307,y\303\247i*\264\364\366M\205\302\235\337\037\016U\331\004\336\321\035\373=X\365\327\361B\3716\361)6h6\177\272\337\252\373\032dv\322\017\207\254\312\rP\226\213\247\305.\321H\0049v\276\200\307\234Q\321\036%\215\\\334\362G.$\"Y\371,]\337\036\004\344Zi\323\234A[\372\003\240\021\371\034\373\315\034;'\354\377\204\263(h)\200\250\300\2572\324\025T\306b\367G\245;\225\001J\3242\256:\303S\025z\277\260\026\233\214\rF\367`*\256T\260\301\312\356\0255\262@\250\305{\270\250\354\002\202/\375\005\243#\2728\2364e\\!\206\0024$\233\346c\215\000\331\010\307\215\3047'\210\203\272r\236\353h\210D\351\r\362\324\346\031\326\266\263Ke\343\273\307{\244\234\014\356\324\310T\221;\274sz\362\202\027I\202n\"\367\202\226\226\212\030\266\364Sh\372\221P\322\260 \177\240r\007\036\202\034\004\235\343\244\346\275\300\352\245\257xoY\351i\232D\364\220\2343B\005\0176KH\202\n\324\177\013\265[\234p\001\200\245eb\212?\323wIx\013\344b\374\255!\010\342\372\363\017\347\022r\370\324\226\007B\217\311r\204\\\203\326Y\246\200H\030\276\347\214\024d2\346\374\022PS\313\303\362\010S\242Q)\337\210\020\255@\022\345\332 \312\020\0267\023<\270\360\254\364'\035T\220\337\200\366\356\234;\253V:\346\220P\242\264\2044\321\315\222\325\340\347\361nA\212$\350\305\025\001\364h\212\216\302Vo#\027\271o=\0360\355\274K\216\r\021k\371I\273\337\3268\347\273\014o\202\232<\320\334\202^\350\364#\303J\335\213\302\034\243V\027\005\336D\314D\007\272\210\311\302\252\366H2O\241\334\350\270&\236\022rY\030\004R\317\304\245\324c&\227\272\203\3274\024(cY\312\274\235,Uv\270\325&M@\373\256\360\316H\233\006\270\3378\266x\003\037V?P~\320j\204\02428\261\030\001\255\020\026#\213\324\254W\377_h\005Q\240\307\205D\205\370 \375J~\002=$\374\352\n\331\266\363*\351\0008\033\365!\223+\216cw7\213\342n\200\242BRd\037;\002\020\343\331\034\317Wu\0108\301\024""\225\324\366\330l\377AZ\023\344\006(@\205\205x/\3373\210\177\312\337\005\263\354\220\240\031\245\242\235\207H\252\206\004\345\317\325\242\265\020\312\203\251\250N\324|+#\221\277\270\017\346\320(\2043"; - PyObject *data = __Pyx_DecompressString(cstring, 2166, 3); + const struct { const unsigned int length: 8; } index[] = {{1},{29},{44},{50},{49},{49},{48},{54},{49},{34},{39},{36},{25},{50},{32},{31},{31},{45},{4},{179},{77},{38},{29},{1},{2},{2},{1},{8},{13},{7},{6},{9},{2},{22},{38},{21},{43},{55},{48},{45},{45},{22},{16},{17},{24},{30},{22},{9},{50},{24},{14},{15},{22},{21},{22},{17},{23},{23},{22},{8},{5},{23},{25},{16},{18},{19},{32},{34},{17},{18},{14},{27},{30},{29},{29},{28},{34},{29},{17},{24},{21},{13},{20},{20},{24},{18},{15},{17},{30},{27},{13},{20},{33},{30},{24},{27},{14},{3},{13},{5},{2},{20},{1},{18},{12},{18},{18},{1},{10},{12},{7},{15},{8},{1},{12},{10},{12},{13},{26},{28},{11},{12},{8},{21},{24},{23},{23},{22},{28},{23},{11},{18},{15},{29},{7},{14},{14},{24},{18},{12},{9},{11},{24},{21},{7},{14},{27},{24},{18},{21},{8},{11},{3},{13},{5},{1},{8},{4},{9},{10},{1},{8},{17},{9},{12},{20},{3},{11},{12},{10},{17},{13},{15},{6},{4},{12},{10},{12},{19},{9},{22},{23},{8},{11},{12},{1},{5},{1},{6},{5},{38},{14},{27},{14},{27},{39},{130},{44},{44},{44},{45},{42},{69},{117},{27},{28},{11},{80},{27},{114},{14},{44},{51},{44},{44},{21},{21},{9},{64},{57},{49}}; + #if (CYTHON_COMPRESS_STRINGS) == 3 && __PYX_LIMITED_VERSION_HEX >= 0x030e0000 /* compression: zstd (2164 bytes) */ +const char* const cstring = "(\265/\375`Y\023UC\000zY\344\022H\340\316:\0070\3143\004\326B\030\305G\030\010\003a \014\204\2010\020Fq\254\021\035\321\266\224\330\236|\347\202\355$!k\0372c\333\366>\277\002\327\316\304L\374\020/v\311WL#,t\004\272\241\355\336(\230\275\020\014\377\000\023\001\036\001#6k2\212\330\227}o\277\017\2030\254c\364?\014'\356\320>\r\363\267\341\231\355|\244Y\256\261K\364\034\304\247\267\345\356\375\316\237\r\335\036j\215C\266?\267\372g\235\343\327v\014q6\206\262\"\256[\235;\230G\230\215\205\226?\347\030\364`#\267\274{O\3427\266*\027TNV\246\225\325\373\273\227\301\207e\360?\222\355x\326\355\367P\365:T\275\267\307\220\333Bve\264\267lK\350\014>\310\261\354\275\310m\307\251T\214j\365\"\215]\321\271\363\377\354g\323(\321\367&2\210s\317:\333\036j\313\363K\310\306\276\375[\207\271\343\220\266\303\330~q%\356\357#\214J\312\314\333\370])\023:\360\337c\367\306\2155\006W4x\227\354\254g\032;\023\361\226\331O\177\277\275\016g\035\267\222\351\274;\267$\333\367\333t\350\331\260\227\360~\346Y\\\317[\366]g\030\355\355\367`\306'Q\260\367\360\356W\347\013z\373\362\327\271\217\341\016=Q\230=\215\343\030\307\276u\273\227K7\334\352\336\0160\035`^0*S\312\245+\251`T)\224\212\213b\014\212\177\253\363\177e\376^~\031\336aw\215\241\313~\2320\305\177\313\276\364\341\246\322\371\264RI\221q\205\257\326\375\276\256\343\316\373\363{=\321\323\260\352\301|RIi\301\2348\220Z\235\311\3252\275b`Z\235\252K\255d\272V\351\272^\272\324\251dr\361`z\241<\240Rw\346\205\"u\253\216tM/%\323}u\343\310\006\226\033N\024\241\200\340\030C\271\327\003q\266\345\335O\364\370\331{\337\033\277\337\367\332\016\2168\366\237\r\365\307\263(D\303\017D\340\3030hq(\024\013{\3362\037\376\026\315\253z\326\250\333\016a3Y~U\277}\347;\237\372\277x\036\0261i\217\\\207x\214F\211c(\333\025\323\367\007\2774\"B\272\242\314\223\211b6\364<\177\267\305\232\210B!\021\253\301\006\252\013\307\254\225,\2344uv\316\232\231\301Qki\013FM\316\317d\231\006p\312J5\240,g7\261y\240\\\220r\322\013\270d\225+d\007\331p\225%\035AA3\304\374\230\036\310\016|\316\314\031N""\336\nxn86\272\222\244\374\310X3<\271\017\t2\201\231bZ\340j20r\004\004\254\350T\214H\020\211@#\367\321\310\265X\253g\243\312\260\2428UN\320I\242\202\250 FC\320\017:\252\245\244\024\203c\345\340\240\245st\226x\254\036\236\\\247\202er\230\034\323Szxnj%.MH\004\0309V\tR\236\250Q\251\301\270\000\340Y\301)=:\253\215\377\010b\233m\024\307\357\376\254\363\357\367j\276\303\275_\217\327\333<\006>\327{\354\277u\230{\376\364\355A<\326\304{\305P\024\211.\315_}\307\2533\246\335K\343\264\313\363\3554\254\357\2039\246s\270W 8\236>\300r\352\312\356\365\364\030\313|\277\355~\377\205\236~.\303\340\351\377\312\362\016o,\274%<\034\340\031ra\242\374>\270\307\177~\244\351R\364)\005\217\316\032\303\206\362\330\232\274u\222\264.\254\351\027\327B]{\360\252\353d\245\241\007}\027%\265>\370\227\013\240^\256\024CU\230\375\006p\353\352\330g8\345\242b\217\001\252h*\017\024(\\\343\3407\336\2662\321lRs\210\001Z\372\001\242\007Mq;\246\034\363\022\2615\301\337\211\221\240p\034EnJn*\010\2622\376\212P\226!kA\035\227\302\313\346\306T\212\320\276\226-\3530\245J\346\3711(L\216P\335\211Vq\260\0100\213:[\010\311\345\002/\372\375\322#\014\010\305\304!\203\3042\024\316@\026\215\020j$\\s\2326\250t#\036G\343\344\2775d\250\337c\241\217\224\355\277\034$\010\337\343\352\373\265e\2125U~\312As\002\245\205z\311\233,\214[\300\202K\3507\020\030\3669\345\260\347\253?}z\211@\253\002Us\211\266\016\301K\032/\221\307\206S\300\271\r\305\203\276\332\366\254WX`I\316\271z\350\241\001\252\341g\267/<\370\\\364\324\014\374S\334;\353\033\377/!o\240C\345\277\027\330\317\007\325\266\332*\254\233\216s!\336a\220\342\212\033\332@\351\217\356\n\303\261\331F\010#,\315M\221\020#Fkc\314T\007\216\305\223\010\376\027\263\024\310d\257\223D\241\014\204a\320\2571\227\206k\235\340\031\205A\222\"!\342\220\325\222]\321\017\002\357$)\t\205\027\026< \024*\t\n\030\r\005\275\210%kk \264\357/k,\234\350\022@\333\233l\251\244o4\354\006\262\346Q\263\005_\316\322/\205\020w/\244\031\262\372\234\340~\363\310+\242\351\024\372\016\260\n0\311G\325s\337u-\340T\320\241b\024\276\256\201\267\201\027I>{\376\330\035)\233$7Mt\r-\033\370\300\357\3468\301!G\276\r\311\001\233\275\017\034\261/\031\006\255^\255\274\325\351\320k\310rb1\202\231pI\332(\322:1\364\276\372\r\311@\255\260\213\320\037\022)Ig\321\342{=\314\244\326\177i\n\024\243\035A\223\324\300\006\032\025\244;vgY\024\353\216\035\004 %e\343\363\000\020yk\343\240\253\217\00012y\251\303\236""\t\336\037\2456\0342\014\000Pm\203x\216/8\022\016u\210\305I&\027\014C\224\350g\t\211f\220\210\366\214ZG\253\243=@\265:\321\315s\205\366\361\375&\320\353\023i\243"; + PyObject *data = __Pyx_DecompressString(cstring, 2164, 3); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #elif (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (2332 bytes) */ -const char* const cstring = "BZh91AY&SY?N\347\217\000\001C\177\377\357\377\377\347\377\377\377\377\277\357\377\374\277\377\377\376@@@@@@@@@@@@@\000@\000`\t\033\276g\255\275\273w:\335\275\347\270\032\321\320\000\001\246\360\036\006Jh\251\352x)\372S\311\202\236\302&\241\2653\0226\246L\365@\302\003F\201\344\2003I\223\323S\323P\365\006\324x\223\322zj\014\220F\201\246\246&\251\345\030@\030\233Q\240\006M\000\001\240\000h\000\000\000h\032h\001\246\204j\010\231A\352i\247\250\006\215\003\020\320\000\006\200\000\000\000\000\000\032d\323h\232\003\022\204\232\006\206\200\000\000\0004\000\000\000\000\000\000\000\000\000\000A\200\002`\000&\t\200\000\000\000\002`\023\001\014\000\001\030\000\000\t\022\020\nz\023\004e4\364L\022b\237\2104\243\320\215\000\001\240\000\000\000\320\0312\006@%\004%=\3003/\003\233\373\2743\\K38\206\207\230\005s\200dv\317L\364 \270\244\274\007\361,\236\376@\204\222\010\004QD$PE$Q/\304q\002\274\301V\215r\022\202\262\306\222S,\270\220F\0341\275j\330\023\211\272\204\022fM\371\323\024eW\2042\375\376$Z\357\022W\273\312\267\222\301T\356\276\022\250\343\264\200mI\222\207\200\3014\022D\327Bj\315qn X\246+\255\260u\221\223\221\360\346\003\3617\200\350\255C\201\367\034L\272\217\332\206\307d\313\007(\276L\005\261\320-isd\224\344\016M\234F\024\220?Z@\340kr\002\025tAQ\320\365\003qj\024\256)\332l\ndRZG\2242\2118qF+\321\264\240Y6\354\315\344\024\2055\263\332\360\271\276\320\337$\205a\252\240\264\262\230\232\246B4<\221uUl\367(\2451c\234\323\304t\364>~\276Y.\372\361.\250:\342\302C9\376M\252T\256i\013\203D\307\035\256\030(\277{V\374\355\035z\301\022\tD\234(7\022\371\322\302x\302C\202>$\243\223\206(\007m\211r\237\211f\243\035\375\003\215\205\302\376\214\234\326\001\005yS\241\212Y\2140(\350O\025:\013\203\\q{\007\027d\271\017',\2446&\304\2060o\014#W\324\252\2339\367\376\216\243V\270U\t\007\303\277\331\0216P}\340l\010\035\356\371$\223\002ux\373\260\006\n \254W\257\306q\265g\265\006\034\360\321\023\004s\006\017]@s#\321ab\311\2059J\017\227\261<\201\276~\206\346\240\200\000\232\275E6\347\002\026\200\0260 j1""\227\324\243\027\260\237=\301r\260\363k\310\244\261\373G\331\235*\265\215tY\0104/\344\275\204\265\323\"\3458|~\316\377Y\200A\r\361\303\203\3114Jnd\347\003\000\323\350\320/\340\274\351\031<\2758E\245\310\303\264\375{\317\367\221\3273\224\204\2620\3104\211#y\217\204\\\022\235\242\305\3379\342\341\000\271jE\231\3230Tr\nH,{\350\214\315C\240'b\203\030\312Q\254a 8^\031\310\303uEM\030g$\263\236\351\300\206#\002\227\0137\234\262\343\022\207\r\207\250\2043\201e\215l\253^\005\327\260h2\2650\324-\313\326\3025\314\0235E\326A{\357\373\230T\003u\365\323\024)\215$R\n)\313d^\315\256\033\2627\334\323\250%\026\231\346\210P\224\005\014\222I\304\223\350\014\342qB\t\372\217f\177\005\363""\214\3538\355p\325n\3477k0\275\006f\214\212q\026\231\232\350\214\242\332\267\323\206\010P\232 \023\035m\334\240&N\031\t\220&\034\335\331\007f~M0\221\331l\261R\362&dI\021\272\351f\202fT]\"\315W<\260\241\215\230o\320\260\260\010\204\247b\342\033\035\227\"\202\276Z.E\352\3572^\200S\n\250\260\030\330\330\330\333\276;\346 \315\327xm\013\030\306o\316\263&_Y,\355\2467a\311\337\032\324\320(\035\241h\356H\252\255\227\221\r\314 \030\305\\U\265x|\313=6l\225k\2514\350\004LxXOI6\335\354:\006\320\302+\202\037\253C5\002\260\n\214\234\265\023bd\310\02045a\027\262\272\240EC\n\356P%-\265\243\202\314\231\025e\203l\030;\315\251V\304\245\341\r^\223\031z\276\372\216\202\330\010M\262\236\225\207rQ\347O\230\342.\244_2\205/\025\272y\r\2465\032\327H!\0328\022\311^br\272\200 vp\345\202\372\027\330\216z\273_ww\214K\222A\333Q\333H\224\211*\017\025\203/P\340 #\273\240\353i0\020\323CM\214\030x\n\217\nY\305\254\316\027 \272\026\354\377\235\262\363\201J\202d\257\262\314[\003\304\25116\234\246W\340\336$X\273D\305\274\211E\254\023\261-T[\034\331Je\200:\002f[\211\370<\014;\331\253\264\260\316\0323\007L\353yj\312\264V\261\034\233\214\305\031\005aOv\020H1N\274\353\253j\356n8\367af\275\205\372\240\234\272A\345\271\324\025n>\211\022\315\372P)\311\362\304oW\207v\024\221\247\244@\3125k\021\254\313Z\375\315A\247\215\311\361\364\235\205HuP?:\250\003\024\271P\337\260K\362\021\267\0244\204\261\374T\\5Q6\212\234\377\210\223!\312\255g\024\nR+\200C)\006ef@R\001\rL\025\207y\335\23402V\"A\203\340P\305\215\022/\377\027rE8P\220?N\347\217"; - PyObject *data = __Pyx_DecompressString(cstring, 2332, 2); + #elif (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (2339 bytes) */ +const char* const cstring = "BZh91AY&SYG)C\235\000\001r\377\377\357\377\377\347\377\377\377\377\277\357\377\374\277\377\377\376@@@@@@@@@@@@@\000@\000`\t\033\276o+\317[\307\255\357]\357`\001\273\024\000i\327<\007\237\tE5\002bOj1=S\314\215Q\21544\324\314\210\323\324\006M4i\2104\3104\323\032\232\014e\006\2324f\221\3511\006D!\252x\024\306\224\3650\232\003\t\246\322z\203CL\215\032\006\231\006\232\000\320\001\240\006\232d\304\323&\2144\320\215A\002\020\332\207\251\352h\r\000\320\000\320\000\000\000\000\000\000\000hd\3654\006jRz\202i\246\247\350\240\366\251\246OH\r6\240=OP\003@\000\000\000\000\003@\000h\001\242\014\000\023\000\0010L\000\000\000\000\023\000\230\010`\000\010\300\000\000H\220M\004\3214\320d\232\236\223\312\237\251\265O\321\245\323\230\0075j\031?1\317v\275\262~\027%N\270MTo\352\000\262f#']\227\027\351\216\234\270L\017@5\253\210\201\253\022\002\026\221B\303,\312\r\273\024N\310$q\254\025\260>\271\032\001\262\277&\010E]\211\324\tR\345\231\274\202\220\246\266{}\3276\260\355$\205a\252\240\264\262\230\232\246B4; \252s\270\324qcA\232\250\246\377x/\305\365\356\037\005\247\000q\r\225\030k\021\027\275G\2266\030\336^\343\030\303\203\020\231\321\275\217\242\325\006\010B!\221\330\363\211nlbj\245(y\231\326\333\004\330\227*!-*f\344'<\010\344\007\364\237\247\010A \347L~A\211\207\n\tK\253{\311\217B\010\221\032~\310\3763/\212\264\030\300\022\006\232\020\230X\261\024Q\320\251O\032\336\213\233r\345\020\351\252\365\024\257Q\224)\246\204Y\014\025\017f\262\252\252\2542\024]\235XaA\020\350\021\250\324\200cH\356F\271\277' \361x\221\243\346\260\t\251\262\3453\2317\354`\205\276\354\016\021\003\033@\375\013\376\375\001-7v\3663\010\014B""CU\034\245\311\020\251\353%\373<\2426\03334f\253\267\211\023T\323\351\351\342\330\005w\ru\332\020p\007\256\277rR\343\3667\227p\355r\317\326\337\364F6\372!\301\343\305I\023s'\004\3440\016\037\203\300/\342\274\311\033=N\274\242\363\005\217\220\375x\363\n\250\017''\273\177e\014\241\231*\266#R\350\241\311\274\352\034\343\034Xxw\005k\25433\rrc\352,_\325J\355I\204\2576\237;a0\313\236\322\" \210\203\330'\221\353\213\241t\327\332=\234\344\036\003\257\337c\336F\025\033\3233\353O\r\001\201\246D(\225\231\243\203\312\270\244\244OAxc\231\272\226 \265\224K\231\260NLJ\342\332\264Q\261\301E)Lc\227\263\311\342\273Xo\020O%|\341\354\323\300\257\210\005||*\225o\322_\216\206\005\324\326I\220T\013\311\216\322\276\"\335\304\021\264\305\230\230\304\320\3506\320\235Go'S(\237#\217k6\223\212\315_Y\003\333\217(H\036\020\333JHnd\355\010\336\254\306\317J\264F\340\242\204\211\007o\204\354\220H\223\367\261\356x\347\364\247\003viX\275g\242\363x\264\317`\327y@\271\221D<\001n\211\253\312H\n\205\275~\313\004\340:\221:\010\304\215\242\034\247\031\350\250M\251\204Z\252\340\"\344\022-\2005\366{\204\204\035\2672\306}Z\220\365\342\001\245y\266\365\241\352@\202\302\336@\304[e\347\331\226\276DZ\341\306\302\222K\325\360\236\202K\277\334\234\241\212L\016\363\036\355[\214\304pj\243\r\nZ\263#\316\200\262+pm\230\253\266\0266\276\311H|\246\312Pv;q\321\242\375\003 S\r[<5\301\371\355Y\310P\240q\020\t\221\234\220\247$6\240\223 \002PK\2768\203\224\3030\254\262\241R\271\013\016\017\206#\300v\215W\035\300\332\272\204\010\341\334\226\365\266\0019eD\220\016\376MpeC\224Y^\216\345\3371\370\271\332\027GB\361\324\361\322%\"sT\036\225\241\230\246\"\"\002\0029Xp\036\006\223I\003M\r60a\336*v%\306k\013\320Z\027>\277\320\331\201\265J\202d\260\265\2646\007}Rbm9L\273\275\270\221d\031(\204\212\245\302Mnx2\224\323\000u\r2f\231rwY\321\252\266.5\206\375\353PuR\317M\332V\375\312\313QFApO\333\204\022\014\323\266\263#@\227\206\216\375q\236\272*\316\250v\307\331I\201RHT\272\202\002\204\017%\005\336Kn\222E\251()\t\331\025Q\016\226\020[b\331v\"\225\311\006\260\246\021\320)\225\0144\0262Tx\331\010\364\003\033\202\033\037\321iS bvH.\206\222x\025\205N\307\2021h\212\204\245K+ \253dq\305/\010\201\222\002(\276/`\0167\211s\374U5\331\333\317\224C\364\263\333\235\n\022f_\003\222\344\231\210Q\004\001\314\323`\332\332$\361\247\263r\023\27544 \032\303+\013\004\256\245N\n\266P\264\247\3030\234\272\243/\265%I\004R\2166lA\001\231\354iy\220\337\215\362\204\204\220#\247\032\321H\271\337\232(\210\227S\021,&\272\033\\K\232md\373\267Qh\257\344$r\215\3255\r\364\273\257\317],\244\234\376\036#\005Z\260\277diA0\221Q\0064m\024\200\320\r\272\352\304E\331\335\353\324\0161\215\014\330\034\334)\246\307H}\025'\276\220""\337\024\\{z?\315\263\250pot\370\347O\261p\225\234'\352;\313\003\364\3570\366 \362\253\256\322\005\255\205\226\252;\2532\334\355\272\352\354\326\242\333\262f\306\036c,kZ'\264\306\216F\022PxwN\230\353\303\025\027\205\216\340-9\321\225\352\334\223\035\320R\2673\237\033J`\271*\363\227\336[\311\216\253\237&M\335\025\255\254\335\357\034\257n\276\224\244\211>\241\247\275\r\266\367-S\213\212\347\225\271\331|\037\010\356\031U\220(\232z\201\231!\357\027\177,\312\347\237}.\263\361\351\231\n\\\035\345\006*K\212v\030&)@\333J\032B]\350\316\032i\242q&\177\361\022d9U,E\002\224\2161e\r\004\031\225\231\001H\0045.\260\360\372\031\303\003%b$\030>~\206,h\221\177\"\356H\247\n\022\010\345(s\240"; + PyObject *data = __Pyx_DecompressString(cstring, 2339, 2); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (2149 bytes) */ -const char* const cstring = "x\332\225WKs\333F\022\016\313\332]\332\221#3\226\022\245\312\217a\254\230\222,\323\253H\311f\035y]4%\331*3\024I\311\321:\233\252\251\0210$\021\203\000\205\001\364\330G\225\217:\362\210#\2168\342\310#\217:\342\310\243~\202\177\302\366\014@\020\024\037N\252l\t\323\257\351\351\376\276\351Q&\273M\024\225\312\2106\016\341\247\242\231\264f(\346\031\222\352Tz\327S\232:\222t\355\230\032&\312#f\032\212V\343\262\322\231Y\327\265P\020\263\245\247&\325dT3H\263\216N\024\263\2166\rrRR\211F\014nmI\246eP6\321\343\365\267k{\224\030R\375w;\254\375Q\207\365?f\277k\231\324h\212C\360\002\375N\257\322d\207&5\252\272\321\010\313\257\303\222\230\212\256\305,\014\010H\215\300@\016\013\237\037\256\371(\263*(Q\346\245HFaH\323Mh\260b*DU\376M\345\354\216v\014_2\222)3\025M\354\033d\376\024\235\300\257&\r\017R\342\316\3057\205B\344\021\234\217'NL\304\232TR\252\nl\376uO\257*\332;\330J\246\247\334\010Y|\375\024e\306\250\217\257\250\231n\031\022\375H*E]\243E\335\244\310\254C\016\371\000\211\240\224\251\252\034\362*RU\224\\\221\240k\334HC\245\255\322\343\365\037\326\021\201\016\031\3647*\231\0141\353PR\tc\224!\275\212\016-E\205R \363\254\t]B;Ut\246[H\243a\257\300.\356`\326)\200\237\232\374\003e\210\006\365\025E\304\340\016\035\310 Y1`\023\345\230r\357m\2422\232\335\013\316\306S\030*;C\r\213\231\250N\270\003\204d\244A\221n\360\266\n\0026\317zE\010\240\324\013\026t\243N\202\016\037R\310*\336\3467\0329TE\nD\006\236\3135\212\026\255\025t\274\204\236\241\305Lv\005=\0079\326x-yZ\242\033\240\222\025\306\375\250\360\316\240\252@Z\266&\325\2328\017\251\010T-.E\362&\336\244*5\351\026\304\217\304O!\221\240\247b\333\014\267\262\232\303\256\334iG{\303\306z\006`\341\376[\032\003\nq\207\314\036\321\360\nep\001\354\364\236}\221A\020vG\253\020\r\240\305$\250m\034\227\3426*\356\024\212\273E\301\272\315\334\213\302Vqw\177\367\365\356k\214Kg\247\360\177\023F/\346G\255\300-C\330\231&)zV\322\r\335\202\261G\231x`\002\021\371\376\022\334\025\024+09\r\"\321C\"\275\343\323\016\353U\254\033J\r\213\213\206\212\247\315\266JjL|\205\256T\223t\231\312\341/\014\027 \343#\030W-M\302\270\006\377z\234\306}\032\307\t<@\335\361\244\235D\327\030Q\257Rt\210\234q\022\216$d\217\212#I8\216~c\2107\206r\243\3116\211fc\010\026\243\3260\251\256\320i\210HW)\024\256\225\303(\374\317A3\267a\330\204\304\031\344\324 \233\202U\311\320\371\313n\3105\316\2578\263\"N\305\330\024\362h\024\203&pg,kz|Q4\376 \307\032\014#xh`\205\341\210\r\240m\260\006\306\r\002$\300\r\2002\377\2179\246\305\322\002?\014\032\356\013?\351\t\346\257\n\334{\344p\201 \tD\213\366\210\232\227\345\323:+\364M\275\tc\034\350\031R\342\310\"j\020\263\377\004\030\232\216\221\200\236\362O8\023\177\263\006\3207(\374E\2431\252V\305\364\014\023\204\257\360i\021\233\251x\304|e\206\024$\036}`K\023\217\rj\030\272\021\274+p\360\267\247\340\265\020clB\017\340g\235\366\246;|\212\376`\331jZ\342""\351q\014/\"\2132\361\234\365\247\346\355\304\207\344'\327\247\317\327\317\377c?\260\313\335\351\317[+6\261\217.\223\363v\322I8\263N\371}\256\233\234\367\347\037\271\253\356\246\227\340\253Y\1776XM\267\363\355\243\310'T\255z)o\301S;\017:\345\253\252e7\355\256\273\377\365\177,^H~\271\022\252\273\267R\335[\237\267\322\255\325\367\271\017\177\036\316\006\364\\|\243;=s~\006Y]s\326\034\020~\321\372\r\022Lu\2233\376\314}[\244\261l\347x\260\333\263\227\311O!\310i\213A\230\267N\335%}-\0175\327\372\311I9\013\216\352-\2657:\354\"=\220(\0346HT\254x \263\365\324.\333$\312\347\207v\242-\002}e\177\346\020\307t7\274\261\266\317\332\3456\tlo:eGvW<2\316\366y\373\250\223\010lg\234#w\312-\264\023}\333\r\373\310ID\266/:\351\316\252\260\365\347\027\335\204;\353\376\332N\2156\266\231\223vV/\373]\234n\347&YN\214aO;9g\337\275\343\355\365r\373\276u\273\365\242%\333\017\2413\253Q~\034\006\351\313\217\251g[\257a\223)\247\340]\363\376\326~\320>\350\344;G\221\321\023\367\310\233\362r\376w\333\035\002\342[\367bXZqs\356\276w\247\275\327I\014\302,\352\355\003\236\342\200\356\033\247<\000\321\264\237\337\367\367\017\374\203\177\306\200\177\275;}\273\365\334\311\270)7\r\340:\377\037\300\246\017\324/\347/\247o\265\022\255T\230\306c\267\354\312\336J[\352\244\006\266\232k\275\365\357\375\325\373\223\310\341\376\242\277\270\321\336\352\334\356\344\272\337d\335F\373\273\316\265\316jw\371QP\351>v\327\274U/\367\341\306'\327\357\331\277\272_z\t\017\340\235q\216x\235v\000)\262\263\002\316?v\244\213T\224\022\207\352j\010\333%\310y\301%\341*\353\022\327\364\270.\365P\240T\230\301\361>;\227Z\263\376\\\306ap\302\271\240\310\205\016t\3632y\327\376\227\373\027\020$\272\311\005'\307\367}e\347\354}\347\216\373\213\307\332q\236p\333+9\372\263\275X7/\366\374R\217\277\376\375\255N\271C\202\315o\316\234\263\326\202\377\305\"\240;\307W\006O\345!\360\002R\271\037b!1\306V\2542\374$\335\271t\330\345\364\373Dwj\331_\316CA\247>=\177ng@\321\023\276\272H\\\021\3368\177\324*\373Sw\341vI~\317!\320Y\007dA\033\236\331\327l\001\317G""\234\222\227\311\373\266\345@\345\276\262Sv\332\376;|&S\255\273\\1s~\344O\275\365\337\376\322M\"\037m\264\241m\263\255\202\217\276\005\024\220\3130\322\032\364\352\261\313\274t\014X\302q\231\203\n9\327E\247T\250\350d\207\377\003\235\306\314V"; - PyObject *data = __Pyx_DecompressString(cstring, 2149, 1); + #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (2147 bytes) */ +const char* const cstring = "x\332\225WKs\333F\022\016\313\332]\332\221Wf,%J\225m\rce)\3132\275\212\224l\326\221\327\005S\224\3152M\221\022\035\305I\252\246 `H\"\206\000\022\003\350\261\217*\037u\344\021G\034q\304\221G\036u\304\221G\375\004\377\204\355\031\200 (>\234TI\344Lw\1773=\335\375M\017\263;\242\242\022\031\221\243C\370T4\223\324\r\305\021\r\251\361\273\001\033\177\024\260\371\307\354w-\223\030M~\010\026\240\337\211*O\0074\211Q\323\215\2430\374:LES\321\265\230\205\001\013\022#0\220\303\300\347Fc>\316\254\006J\224y\301\235Q(\322t\023\022\254\230\212\250*\377&r\266\240\035\303HF2\241\246\242\361}\003\317\237\240\023\370j\222\360 e\006.\275)\026#Dp>\346\270h\"\332$\222RS`\363\257\372zU\321\336\301V29eF\310b\363'(3A}|EMu\313\220\310G\\)\351\032)\351&Af\003|\310\005\225\010J\231\250\312!\213\"Qy\310\025\t\262\306\2144T\316\227\037m~\277\211D\310\220A~#\222I\021\265\016%U\244\224P\244\327\320\241\245\250\020\nd\2365!K\250PCg\272\2054\022\346\n\354\342\000\263A\240\370\211\311\006(#j\020_\036D\014p\310@\006\311\212\001\233(\307\204\241wD\225\222\354~p6\346\302H\330):\262\250\211\032\"\003\300\222T<\"H7XZ9\001\233g\375 \004\245\324_,\310FC\0142|H\300\253x\232\337h\342\241\312]\020e\340\271\\'h\305ZC\307\017\320S\264\222\311d\327\3203P`\215\005\223\371\305\323\001:Y\241\014H8<\203j\274\324\262u\251\336\3049\360\205\227\325\312\203H\336\304\333D%&\311\303\006\221\370\tx\022$\225\357\233aVVs\024\312@\005\355\r\235\210\014\252\205\341\363\032\005\0161@Nl\212\0220+\302\2603\262|p\204\024j\231\020`/\210\271\243\030\324\234\340\036\273\333`\003v\377\005\333\200}\211(\365\306\241n|\334'n|jN;\372\300\270\000\271\031\215@\211\234\014\315\367\210(\017\t\016\340\022a\253C\231\006\t\207se2}^\213h\350\034\252xH\324\354W}-p\205\3412u\361(\223Uh\220RY\323\241\006k\242\245\232\010c\203\310\226D0F\262\305kE\323\265G""\300\236c\250\"\320J\254\2400\216n\277\3075KU\037s?\262\315\263\323\255\340:\n\210\373\257\007\301\315g\205u$Tq~\373E\036\347\204\262\220+T\337\342b\341u\241\232\177\375<\277\275S\024^\354\343\355=\341\240\\\024J\302^L\270\373\246\232\337\033\221\216\010\366\363\302^\356\345\316\356\036\364\213\261\342\215\361\342\315\035\210k\t\010\3063\301?\262Q\020$~\233`\334\027CMQ\240\366U\005$E\220e\226\364h\036\021#\222\014H1\020E\315\020\262\314n\355\252\316\274\231\246\337\347\361\035X\204\034\212\004\021\177\006\022\326\010\006\263\021\322\014T\274e\035@\306b\033\217\323F\035y\254rc\232rs\262n\270\253\216\263(\217(w\200LC\021\005\376\215=[\234\364qaih\022\322|Xv:\002\372\221Sk\033\336Gd \217\310<\220\320!`\201\006\270HP\324O\210\361\\\267\202#\354\233\272!\306\314\007Z\006S$B#\025\273\021b\023ed\347*4\024\236\366=B\201\324\205\376[.2x\003\215t\362\326\303Z:F>\342\022\277\223J\205bi\267\304Y\266-$?\271>{\276y\376\037\373\276]\351\315~\326^""\263E\273u\231\\\264\223N\302\231w*\357\205^r\321_|\350\256\273\333^\202\315\346\375\371`6\333\311uZ\021&4\\\367R\336\262'\206\206\301L\355\336\357V\206\014A\265\352\246\335M\367\277\376\017\245\013\311\257\354\205\352\336\255T\357\326g\355t{\375\275\360\341\317\243\276\201\236\211o\364f\347\316\317\300\307k\316\206\003\302\317\333\277\201\273\251^r\316\237[\262\271S\253\266\300\026\273=\177\231\374\024\0269mSX\346\255\323p\305\201\226-\265\320~\355\244\234eG\365\036t\266\272\364\"=\344(\203\232\355'v\305\026#\017\276\357$:\034\372\245\375WGtLw\313\233h\373\264S\351\210\201\355M\247\342\310\356Z\020\233q\266\317:\255n\"\260\235sZ\356\214[\354$\006\266[v\313ID\266\317\273\351\356:\267\365\027W\334\204;\357\376\332I\2157\266\251\223v\326/\007Y\234\355\010\323,\247\256a\317:\202Su\357x\373}\337\276k\337n?o\313\366\337 \027\353\221\177,\361\351\313\217\251\347\333\257`\223\031\247\350]\363\376\321\271\3379\350\346\272\255\310\350\261\333\362f<\301\377v\247+\202\370\326\275X\365\254\271\202[\365\356t\366\273\211\341\302\212\262y\237\271\030\327\245\320\240\242\277v*C\365\231\366sU\277z\340\037\374\024\343\300\365\336\354\355\3663'\343\246\3344T\326\371\377\240f\006U\372\305\342\345\354\255v\242\235\n=z\344V\\\331[\353H\335\324\220G\013\355\267\376\275\277{\177\342\356,\255\370+[\235|\367vW\350}\235u\217:\337v\257u\327{\253\017\203\240\017\nw\303[\367\204\0177>\271~\317\376\325\375\302KxP\333\031\247\305BV\200\242\221\2355\000\377\320\225.R\221K\214P\353!\013\263\256\350\232\036\314.\223w\355_\334\277@$\023\275\344\262#\260\005^\332\202]u\356\270?{\264\023\257vf{e3\177>HB\261{\363b\337/\367Y\350/\345\273\225./\344\353\275\233s\347\264\275\354\177\276\306.\01063\332\363\376\302C w\253\267\220\016\263\221\036\266}\314\274\213l\263\020\270toa)\254\205\304\373Dof\325_\315Adf>=\177fg`\221t(|y\221\270\"\274q\376\260]\361g\356\302\035\221\374\216\345\262\273\t\325\002\361|j_\263y\311=d4\273L.\331\226\003e\360\245\235\262\323\366?a\230L\265\3572\305\334y\313\237y\353\277\375\271""\227D>\332\352@\374\347\333E\037}\003\351\024/\303\2256 \350\217\\\352\245c\025\302\201\253\254:\220s\035\312d\331U!\242\323\001\377\007\\/\2703"; + PyObject *data = __Pyx_DecompressString(cstring, 2147, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #else /* compression: none (5257 bytes) */ -const char* const bytes = "'.Failed embed integrity check.Failed to convert C string to Python string.Failed to extend graph with DrawPlanar structures.Failed to extend graph with K23Search structures.Failed to extend graph with K33Search structures.Failed to extend graph with K4Search structures.Failed to extend graph with Outerplanarity structures.Failed to extend graph with Planarity structures.Failed to perform embed operation.Failed to render embedding to C string.Failed to render embedding to file 'Graph is not initialized.Invalid destination graph: wrapped graphP is NULL.Invalid graph format specifier \"Invalid link index for ulink: 'Invalid link index for vlink: 'Invalid source graph: wrapped graphP is NULL.NoneNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.Source and destination graphs must have the same order to copy graphP struct.Source graph has not been initialized.Unable to add edge (u, v) = ('., ?add_note and vlink = disableenable' failed.gcgp_CopyGraph() failed.gp_DeleteEdge() failed: invalid edge 'gp_DupGraph() failed.gp_EdgeInUse() failed: invalid edge index 'gp_EnsureEdgeCapacity() failed to set edge capacity to gp_GetFirstEdge() failed: invalid vertex intex 'gp_GetNeighbor() failed: invalid edge index 'gp_GetNextEdge() failed: invalid edge index 'gp_InitGraph() failed.gp_New() failed.gp_Read() failed.gp_Write() of graph to '' is not a valid vertex label.\" is not one of 'gam'.isenabledno default __reduce__ due to non-trivial __cinit__planarity/full/graph.pyx) with ulink = EMBEDFLAGS_DRAWPLANAREMBEDFLAGS_OUTERPLANAREMBEDFLAGS_PLANAREMBEDFLAGS_SEARCHFORK23EMBEDFLAGS_SEARCHFORK33EMBEDFLAGS_SEARCHFORK4FileNameGraphGraph.__reduce_cython__Graph.__setstate_cython__Graph.gp_AddEdgeGraph.gp_CopyGraphGraph.gp_DeleteEdgeGraph.gp_DrawPlanar_RenderToFileGraph.gp_DrawPlanar_RenderToStringGraph.gp_DupGraphGraph.gp_EdgeArraySizeGraph.gp_EdgeArra""yStartGraph.gp_EdgeInUseGraph.gp_EdgeInUseArraySizeGraph.gp_EmbedGraph.gp_EnsureEdgeCapacityGraph.gp_ExtendWith_DrawPlanarGraph.gp_ExtendWith_K23SearchGraph.gp_ExtendWith_K33SearchGraph.gp_ExtendWith_K4SearchGraph.gp_ExtendWith_OuterplanarityGraph.gp_ExtendWith_PlanarityGraph.gp_FindEdgeGraph.gp_GetEdgeCapacityGraph.gp_GetFirstEdgeGraph.gp_GetFirstVertexGraph.gp_GetLastVertexGraph.gp_GetNGraph.gp_GetNeighborGraph.gp_GetNextEdgeGraph.gp_GetVertexDegreeGraph.gp_InitGraphGraph.gp_IsEdgeGraph.gp_IsVertexGraph.gp_ReadGraph.gp_ReinitializeGraphGraph.gp_TestEmbedResultIntegrityGraph.gp_VertexInRangeAscendingGraph.gp_WriteNILNONEMBEDDABLENOTOKOK__Pyx_PyDict_NextRefaasyncio.coroutinescheck_resultcline_in_tracebackcopy_of_orig_grapheembedFlagsembed_resultencodedencoded_version__func__g__getstate__gp_AddEdgegp_CopyGraphgp_DeleteEdgegp_DrawPlanar_RenderToFilegp_DrawPlanar_RenderToStringgp_DupGraphgp_EdgeArraySizegp_EdgeArrayStartgp_EdgeInUsegp_EdgeInUseArraySizegp_Embedgp_EnsureEdgeCapacitygp_ExtendWith_DrawPlanargp_ExtendWith_K23Searchgp_ExtendWith_K33Searchgp_ExtendWith_K4Searchgp_ExtendWith_Outerplanaritygp_ExtendWith_Planaritygp_FindEdgegp_GetEdgeCapacitygp_GetFirstEdgegp_GetFirstVertexgp_GetLastVertexgp_GetLibPlanarityVersionFullgp_GetNgp_GetNeighborgp_GetNextEdgegp_GetProjectVersionFullgp_GetVertexDegreegp_InitGraphgp_IsEdgegp_IsVertexgp_Readgp_ReinitializeGraphgp_TestEmbedResultIntegritygp_VertexInRangeAscendinggp_Writeinfile_nameint_is_coroutineitemsm__main__modemode_code__module__n__name__new_edge_capacitynew_graphoutfile_nameplanarity.full.graphpop__pyx_state__qualname____reduce____reduce_cython____reduce_ex__renditionStringreturnself__set_name__setdefault__setstate____setstate_cython__src_graphsrc_graph_uninit_errorstring_conversion_error__test__theFileNametheGraph_dupuulinkvvaluesvlink\320\004\030\230\001\360\010\000\t\014\2104\210{\230#\230Q\330\014\022\220,\230a\230q\340\010\030\230\010\240\001\240\024\240Q\200A\330\010\030\320\030+\2501\250D\260\001\200A\330\010""\024\320\024+\2501\250D\260\014\270C\270q\330\014\022\220,\230a\230q\200A\330\010\024\320\0241\260\021\260$\260l\300#\300Q\330\014\022\220,\230a\230q\200A\330\010\024\320\024*\250!\2504\250|\320;N\310c\320QR\330\014\022\220,\230a\330\020\021\330\020\022\220!\2201\200A\360\006\000\t\014\2104\210{\230#\230Q\330\014\022\220,\230a\330\020\021\360\006\000\t\n\330\014\017\210y\230\010\240\003\2403\240a\330\020\026\220j\240\001\240\021\330\010\017\320\017\037\230q\330\014\022\220*\230A\330\020\021\330\023\024\340\010\013\2104\210x\220s\230#\230Y\240h\250a\330\014\022\220*\230A\330\020\021\360\006\000\t\025\220M\240\021\240$\240l\260)\270<\300s\310!\330\014\022\220,\230a\230q\200A\330\010\030\320\030*\250!\2504\250q\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\0208\270\001\270\021\360\006\000\t\031\230\016\240a\240t\250<\260q\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\020=\270Q\270a\360\006\000\t\031\230\r\240Q\240d\250,\260a\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\020?\270q\300\001\360\006\000\t\031\230\017\240q\250\004\250L\270\001\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\330\020B\300!\3001\360\006\000\t\031\320\030(\250\001\250\024\250\\\270\021\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\340\010\030\320\030+\2501\250D\260\014\270A\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\340\010\030\230\014\240A\240T\250\034\260S\270\001\200A\330\010\013\2106\220\023\220B\220d\230&\240\003\2401\330\014\022\220,\230a\330\0201\260\021\260!\340\010\013\2106\220\023\220B\220d\230&\240\003\2401\330\014\022\220,\230a\330\0201\260\021\260!\340\010\024\220K\230q\240\004\240L\260\003\2607\270#\270W\300C\300q\330\014\022\220,\230a\330\020/\250q\260\004\260A\3205F\300a\300q\330\020\036\230a\230q\200A\330\010\024\320\024,\250A\250T\260\034\270S""\300\001\330\014\022\220,\230a\230q\200A\330\010\024\220M\240\021\240$\240l\260#\260S\270\001\330\014\022\220,\230a\230q\200A\330\010%\240Q\330\010\024\320\0241\260\021\260$\260l\300!\320CT\320TW\320WX\330\014\022\220,\230a\230q\340\010\t\330\014\023\220?\240'\250\021\250!\330\010\017\210}\230A\330\014\022\220,\230a\330\020\021\330\027\030\340\014\020\220\001\220\021\200A\330\010\024\320\024-\250Q\250d\260,\270c\300\021\330\014\022\220,\230a\230q\200A\330\010\025\220Y\320\0360\260\005\260S\270\001\330\037(\320(<\270E\300\023\300A\330%.\250m\2705\300\003\3001\330*+\330\010\013\2104\210q\330\014\022\220*\230A\330\0203\2601\260A\360\n\000\t\036\230\\\250\027\260\001\260\021\330\010'\240q\340\010\024\220I\230Q\230d\240,\250m\270;\300c\310\021\330\014\022\220,\230a\330\020*\250!\2501\200A\330\010\030\320\030)\250\021\250$\250a\200A\330\010\030\320\030.\250a\250t\2601\200A\330\021&\240a\240t\2501\200A\330\010\t\330\014\016\210c\220\024\320\025'\240s\250!\330\025/\250q\260\004\260L\300\001\200A\340\010\035\230[\250\007\250q\260\001\330\010$\240A\340\010\024\220H\230A\230T\240\034\250Z\260s\270!\330\014\022\220,\230a\230q\200A\340\010\035\230\\\250\027\260\001\260\021\330\010'\240q\340\010\024\320\024/\250q\260\004\260L\300\r\310S\320PQ\330\014\022\220,\230a\320\037E\300Q\300a\200A\330\010\t\330\r\017\210s\220$\320\026(\250\004\250A\330\r\017\210r\220\024\320\025&\240d\250!\330\025\037\230q\240\004\240L\260\001\200A\330\010\t\330\r\017\210s\220$\320\026(\250\004\250A\330\r\017\210s\220$\320\026'\240t\2501\330\025!\240\021\240$\240l\260!\200\001\330\004*\320*C\3001\330\004\013\210?\230'\240\021\240!\200\001\330\004*\320*H\310\001\330\004\013\210?\230'\240\021\240!\200\001\330\004\n\210+\220Q\320\004\035\230Q\330\0106\260l\300!\3004\300q\330\010\013\210=\230\003\2301\330\014\022\220+\230Q\230a\340\010\037\230u\240A\330\021\031\230\021\230!\2309\240A\330\010\021\220\035\230a\340\010\017\210q\320\004Y\320YZ\330\010 \320 <\270A\330\020\024\220L\320 2\260,\270a\340\010\013\210=""\230\003\2303\230d\240-\250s\260!\330\014\022\220,\230a\230q\340\010\017\210q\320\004*\250!\330\010 \240\t\250\021\250$\250l\270!\330\010\013\210=\230\003\2303\230d\240-\250s\260!\330\014\022\220,\230a\230q\340\010\017\210q"; + #else /* compression: none (5209 bytes) */ +const char* const bytes = ".Failed embed integrity check.Failed to convert C string to Python string.Failed to extend graph with DrawPlanar structures.Failed to extend graph with K23Search structures.Failed to extend graph with K33Search structures.Failed to extend graph with K4Search structures.Failed to extend graph with Outerplanarity structures.Failed to extend graph with Planarity structures.Failed to perform embed operation.Failed to render embedding to C string.Failed to render embedding to file 'Graph is not initialized.Invalid destination graph: wrapped graphP is NULL.Invalid graph format specifier \"Invalid link index for ulink: 'Invalid link index for vlink: 'Invalid source graph: wrapped graphP is NULL.NoneNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.Source and destination graphs must have the same order to copy graphP struct.Source graph has not been initialized.Unable to add edge (u, v) = (''., ?add_note and vlink = disableenable' failed.gcgp_CopyGraph() failed.gp_DeleteEdge() failed: invalid edge 'gp_DupGraph() failed.gp_EdgeInUse() failed: invalid edge index 'gp_EnsureEdgeCapacity() failed to set edge capacity to gp_GetFirstEdge() failed: invalid vertex intex 'gp_GetNeighbor() failed: invalid edge index 'gp_GetNextEdge() failed: invalid edge index 'gp_InitGraph() failed.gp_New() failed.gp_Read() failed.gp_Write() of graph to '' is not a valid vertex label.\" is not one of 'gam'.isenabledno default __reduce__ due to non-trivial __cinit__planarity/full/graph.pyx) with ulink = AT_EDGE_CAPACITY_LIMITEMBEDFLAGS_DRAWPLANAREMBEDFLAGS_OUTERPLANAREMBEDFLAGS_PLANAREMBEDFLAGS_SEARCHFORK23EMBEDFLAGS_SEARCHFORK33EMBEDFLAGS_SEARCHFORK4FileNameGraphGraph.__reduce_cython__Graph.__setstate_cython__Graph.gp_AddEdgeGraph.gp_CopyGraphGraph.gp_DeleteEdgeGraph.gp_DrawPlanar_RenderToFileGraph.gp_DrawPlanar_RenderToStringGraph.gp_DupGraphGraph.gp_EdgeInUs""eGraph.gp_EmbedGraph.gp_EnsureEdgeCapacityGraph.gp_ExtendWith_DrawPlanarGraph.gp_ExtendWith_K23SearchGraph.gp_ExtendWith_K33SearchGraph.gp_ExtendWith_K4SearchGraph.gp_ExtendWith_OuterplanarityGraph.gp_ExtendWith_PlanarityGraph.gp_FindEdgeGraph.gp_GetEdgeCapacityGraph.gp_GetFirstEdgeGraph.gp_GetNGraph.gp_GetNeighborGraph.gp_GetNextEdgeGraph.gp_GetVertexDegreeGraph.gp_InitGraphGraph.gp_IsEdgeGraph.gp_IsVertexGraph.gp_LowerBoundEdgeStorageGraph.gp_LowerBoundVerticesGraph.gp_ReadGraph.gp_ReinitGraphGraph.gp_TestEmbedResultIntegrityGraph.gp_UpperBoundEdgeStorageGraph.gp_UpperBoundEdgesGraph.gp_UpperBoundVerticesGraph.gp_WriteNILNONEMBEDDABLENOTOKOK__Pyx_PyDict_NextRefaasyncio.coroutinescheck_resultcline_in_tracebackcopy_of_orig_grapheembedFlagsembed_resultencodedencoded_version__func__g__getstate__gp_AddEdgegp_CopyGraphgp_DeleteEdgegp_DrawPlanar_RenderToFilegp_DrawPlanar_RenderToStringgp_DupGraphgp_EdgeInUsegp_Embedgp_EnsureEdgeCapacitygp_ExtendWith_DrawPlanargp_ExtendWith_K23Searchgp_ExtendWith_K33Searchgp_ExtendWith_K4Searchgp_ExtendWith_Outerplanaritygp_ExtendWith_Planaritygp_FindEdgegp_GetEdgeCapacitygp_GetFirstEdgegp_GetLibPlanarityVersionFullgp_GetNgp_GetNeighborgp_GetNextEdgegp_GetProjectVersionFullgp_GetVertexDegreegp_InitGraphgp_IsEdgegp_IsVertexgp_LowerBoundEdgeStoragegp_LowerBoundVerticesgp_Readgp_ReinitGraphgp_TestEmbedResultIntegritygp_UpperBoundEdgeStoragegp_UpperBoundEdgesgp_UpperBoundVerticesgp_Writeinfile_nameint_is_coroutineitemsm__main__modemode_code__module__n__name__new_edge_capacitynew_graphoutfile_nameplanarity.full.graphpop__pyx_state__qualname____reduce____reduce_cython____reduce_ex__renditionStringreturnself__set_name__setdefault__setstate____setstate_cython__src_graphsrc_graph_uninit_errorstring_conversion_error__test__theFileNametheGraph_dupuulinkvvaluesvlink\320\004\030\230\001\360\010\000\t\014\2104\210{\230#\230Q\330\014\022\220,\230a\230q\340\010\030\230\010\240\001\240\024\240Q\200A\330\010\030\320\030+\2501\250D\260\001\200A\330\010\024""\320\024+\2501\250D\260\014\270C\270q\330\014\022\220,\230a\230q\200A\330\010\030\320\0301\260\021\260$\260a\200A\330\010\024\320\0241\260\021\260$\260l\300#\300Q\330\014\022\220,\230a\230q\200A\330\010\024\320\024*\250!\2504\250|\320;N\310c\320QR\330\014\022\220,\230a\330\020\021\330\020\022\220!\2201\200A\360\006\000\t\014\2104\210{\230#\230Q\330\014\022\220,\230a\330\020\021\360\006\000\t\n\330\014\017\210y\230\010\240\003\2403\240a\330\020\026\220j\240\001\240\021\330\010\017\320\017\037\230q\330\014\022\220*\230A\330\020\021\330\023\024\340\010\013\2104\210x\220s\230#\230Y\240h\250a\330\014\022\220*\230A\330\020\021\360\006\000\t\025\220M\240\021\240$\240l\260)\270<\300s\310!\330\014\022\220,\230a\230q\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\0208\270\001\270\021\360\006\000\t\031\230\016\240a\240t\250<\260q\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\020=\270Q\270a\360\006\000\t\031\230\r\240Q\240d\250,\260a\200A\330\010\013\2104\210t\220:\230Q\230a\330\014\022\220,\230a\330\020?\270q\300\001\360\006\000\t\031\230\017\240q\250\004\250L\270\001\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\330\020B\300!\3001\360\006\000\t\031\320\030(\250\001\250\024\250\\\270\021\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\340\010\030\320\030+\2501\250D\260\014\270A\200A\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\330\010\013\2104\210t\220<\230q\240\001\330\014\022\220,\230a\230s\240!\2401\340\010\030\230\014\240A\240T\250\034\260S\270\001\200A\330\010\013\2106\220\023\220B\220d\230&\240\003\2401\330\014\022\220,\230a\330\0201\260\021\260!\340\010\013\2106\220\023\220B\220d\230&\240\003\2401\330\014\022\220,\230a\330\0201\260\021\260!\340\010\024\220K\230q\240\004\240L\260\003\2607\270#\270W\300C\300q\330\014\022\220,\230a\330\020/\250q\260\004\260A\3205F\300a\300q\330\020\036\230a\230q\200A\330\010\024\320\024,\250A\250T\260\034\270S""\300\001\330\014\022\220,\230a\230q\200A\330\010\024\220M\240\021\240$\240l\260#\260S\270\001\330\014\022\220,\230a\230q\200A\330\021 \240\001\240\024\240Q\200A\330\010%\240Q\330\010\024\320\0241\260\021\260$\260l\300!\320CT\320TW\320WX\330\014\022\220,\230a\230q\340\010\t\330\014\023\220?\240'\250\021\250!\330\010\017\210}\230A\330\014\022\220,\230a\330\020\021\330\027\030\340\014\020\220\001\220\021\200A\330\010\024\320\024-\250Q\250d\260,\270c\300\021\330\014\022\220,\230a\230q\200A\330\010\025\220Y\320\0360\260\005\260S\270\001\330\037(\320(<\270E\300\023\300A\330%.\250m\2705\300\003\3001\330*+\330\010\013\2104\210q\330\014\022\220*\230A\330\0203\2601\260A\360\n\000\t\036\230\\\250\027\260\001\260\021\330\010'\240q\340\010\024\220I\230Q\230d\240,\250m\270;\300c\310\021\330\014\022\220,\230a\330\020*\250!\2501\200A\330\010\030\320\030.\250a\250t\2601\200A\340\010\035\230[\250\007\250q\260\001\330\010$\240A\340\010\024\220H\230A\230T\240\034\250Z\260s\270!\330\014\022\220,\230a\230q\200A\340\010\035\230\\\250\027\260\001\260\021\330\010'\240q\340\010\024\320\024/\250q\260\004\260L\300\r\310S\320PQ\330\014\022\220,\230a\320\037E\300Q\300a\200A\330\010\t\330\r\017\210s\220$\320\026,\250D\260\001\330\r\017\210r\220\024\320\025+\2504\250q\330\025!\240\021\240$\240l\260!\200A\330\010\t\330\r\017\210s\220$\320\026/\250t\2601\330\r\017\210r\220\024\320\025.\250d\260!\330\025\037\230q\240\004\240L\260\001\200\001\330\004*\320*C\3001\330\004\013\210?\230'\240\021\240!\200\001\330\004*\320*H\310\001\330\004\013\210?\230'\240\021\240!\200\001\330\004\n\210+\220Q\320\004\035\230Q\330\0106\260l\300!\3004\300q\330\010\013\210=\230\003\2301\330\014\022\220+\230Q\230a\340\010\037\230u\240A\330\021\031\230\021\230!\2309\240A\330\010\021\220\035\230a\340\010\017\210q\320\004Y\320YZ\330\010 \320 <\270A\330\020\024\220L\320 2\260,\270a\340\010\013\210=\230\003\2303\230d\240-\250s\260!\330\014\022\220,\230a\230q\340\010\017\210q\320\004*\250!\330\010 \240\t\250\021\250$\250l\270!\330""\010\013\210=\230\003\2303\230d\240-\250s\260!\330\014\022\220,\230a\230q\340\010\017\210q"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif PyObject **stringtab = __pyx_mstate->__pyx_string_tab; Py_ssize_t pos = 0; - for (int i = 0; i < 191; i++) { + for (int i = 0; i < 190; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 52) PyUnicode_InternInPlace(&string); @@ -11674,7 +11481,7 @@ const char* const bytes = "'.Failed embed integrity check.Failed to convert C st stringtab[i] = string; pos += bytes_length; } - for (int i = 191; i < 224; i++) { + for (int i = 190; i < 221; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; @@ -11685,15 +11492,15 @@ const char* const bytes = "'.Failed embed integrity check.Failed to convert C st } } Py_XDECREF(data); - for (Py_ssize_t i = 0; i < 224; i++) { + for (Py_ssize_t i = 0; i < 221; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { - PyObject **table = stringtab + 191; - for (Py_ssize_t i=0; i<33; ++i) { + PyObject **table = stringtab + 190; + for (Py_ssize_t i=0; i<31; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #if PY_VERSION_HEX < 0x030E0000 if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1) @@ -11765,199 +11572,194 @@ static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; { - const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 28}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_encoded_version}; - __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetProjectVersionFull, __pyx_mstate->__pyx_kp_b_iso88591_C1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 40}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n}; + __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_InitGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_M_l_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 33}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_encoded_version}; - __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetLibPlanarityVersionFull, __pyx_mstate->__pyx_kp_b_iso88591_H, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 44}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ReinitGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 49}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; - __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_IsEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_s_A_r_d_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 47}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_new_edge_capacity}; + __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EnsureEdgeCapacity, __pyx_mstate->__pyx_kp_b_iso88591_A_4_NcQR_a_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 53}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetEdgeCapacity, __pyx_mstate->__pyx_kp_b_iso88591_A_1D, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 56}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EdgeArrayStart, __pyx_mstate->__pyx_kp_b_iso88591_A_4q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetN, __pyx_mstate->__pyx_kp_b_iso88591_4_Q_aq_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 59}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; - __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EdgeInUse, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_Qa_Qd_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 65}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_src_graph, __pyx_mstate->__pyx_n_u_src_graph_uninit_error}; + __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_CopyGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_4_Q_a_y_3a_j_q_A_4xs_Yha_A_M_l, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 67}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EdgeArraySize, __pyx_mstate->__pyx_kp_b_iso88591_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 89}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_theGraph_dup, __pyx_mstate->__pyx_n_u_new_graph}; + __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DupGraph, __pyx_mstate->__pyx_kp_b_iso88591_Q_6l_4q_1_Qa_uA_9A_a_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 70}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EdgeInUseArraySize, __pyx_mstate->__pyx_kp_b_iso88591_A_at1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; + const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 100}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_u, __pyx_mstate->__pyx_n_u_v}; + __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_FindEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_as_1_4t_q_as_1_AT_S, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 73}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 108}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_v}; - __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetFirstEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_a_B_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetVertexDegree, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_as_1_1D_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 81}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; - __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetNextEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; + const __Pyx_PyCode_New_function_description descr = {5, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 114}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_u, __pyx_mstate->__pyx_n_u_ulink, __pyx_mstate->__pyx_n_u_v, __pyx_mstate->__pyx_n_u_vlink}; + __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_AddEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_6_Bd_1_a_1_6_Bd_1_a_1_Kq_L_7_W, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 89}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 129}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; - __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetNeighbor, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad; - } - { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 97}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_v}; - __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_IsVertex, __pyx_mstate->__pyx_kp_b_iso88591_A_s_A_s_t1_l, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DeleteEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_8_at_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 104}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 137}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetFirstVertex, __pyx_mstate->__pyx_kp_b_iso88591_A_4q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_LowerBoundEdgeStorage, __pyx_mstate->__pyx_kp_b_iso88591_A_1_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 107}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 140}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetLastVertex, __pyx_mstate->__pyx_kp_b_iso88591_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad; - } - { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 110}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_v}; - __pyx_mstate_global->__pyx_codeobj_tab[13] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_VertexInRangeAscending, __pyx_mstate->__pyx_kp_b_iso88591_A_c_s_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[13])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_UpperBoundEdgeStorage, __pyx_mstate->__pyx_kp_b_iso88591_A_1_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 116}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[14] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetN, __pyx_mstate->__pyx_kp_b_iso88591_4_Q_aq_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[14])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 143}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; + __pyx_mstate_global->__pyx_codeobj_tab[13] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_IsEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_s_t1_r_d_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[13])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 125}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n}; - __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_InitGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_M_l_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 150}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; + __pyx_mstate_global->__pyx_codeobj_tab[14] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EdgeInUse, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_Qa_Qd_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[14])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 129}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 158}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ReinitializeGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_at1_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_UpperBoundEdges, __pyx_mstate->__pyx_kp_b_iso88591_A_1D, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 132}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_src_graph, __pyx_mstate->__pyx_n_u_src_graph_uninit_error}; - __pyx_mstate_global->__pyx_codeobj_tab[17] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_CopyGraph, __pyx_mstate->__pyx_kp_b_iso88591_A_4_Q_a_y_3a_j_q_A_4xs_Yha_A_M_l, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[17])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 161}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; + __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetNextEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 156}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_theGraph_dup, __pyx_mstate->__pyx_n_u_new_graph}; - __pyx_mstate_global->__pyx_codeobj_tab[18] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DupGraph, __pyx_mstate->__pyx_kp_b_iso88591_Q_6l_4q_1_Qa_uA_9A_a_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[18])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 169}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; + __pyx_mstate_global->__pyx_codeobj_tab[17] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetNeighbor, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_q_q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[17])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 167}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_infile_name, __pyx_mstate->__pyx_n_u_encoded, __pyx_mstate->__pyx_n_u_FileName}; - __pyx_mstate_global->__pyx_codeobj_tab[19] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Read, __pyx_mstate->__pyx_kp_b_iso88591_A_q_A_HAT_Zs_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[19])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 177}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_v}; + __pyx_mstate_global->__pyx_codeobj_tab[18] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetFirstEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_a_B_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[18])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 175}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_outfile_name, __pyx_mstate->__pyx_n_u_mode, __pyx_mstate->__pyx_n_u_mode_code, __pyx_mstate->__pyx_n_u_encoded, __pyx_mstate->__pyx_n_u_theFileName}; - __pyx_mstate_global->__pyx_codeobj_tab[20] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Write, __pyx_mstate->__pyx_kp_b_iso88591_A_Y_0_S_E_A_m5_1_4q_A_31A_q_IQd, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[20])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 185}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[19] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_LowerBoundVertices, __pyx_mstate->__pyx_kp_b_iso88591_A_at1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[19])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 195}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_u, __pyx_mstate->__pyx_n_u_v}; - __pyx_mstate_global->__pyx_codeobj_tab[21] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_FindEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_as_1_4t_q_as_1_AT_S, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[21])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 188}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[20] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_UpperBoundVertices, __pyx_mstate->__pyx_kp_b_iso88591_A_at1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[20])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 203}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 191}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_v}; - __pyx_mstate_global->__pyx_codeobj_tab[22] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetVertexDegree, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_q_as_1_1D_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[22])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[21] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_IsVertex, __pyx_mstate->__pyx_kp_b_iso88591_A_s_D_r_4q_l, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[21])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 209}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 198}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[23] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetEdgeCapacity, __pyx_mstate->__pyx_kp_b_iso88591_A_1D, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[23])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[22] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K23Search, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[22])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 212}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_new_edge_capacity}; - __pyx_mstate_global->__pyx_codeobj_tab[24] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_EnsureEdgeCapacity, __pyx_mstate->__pyx_kp_b_iso88591_A_4_NcQR_a_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[24])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 202}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[23] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K33Search, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[23])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {5, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 218}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_u, __pyx_mstate->__pyx_n_u_ulink, __pyx_mstate->__pyx_n_u_v, __pyx_mstate->__pyx_n_u_vlink}; - __pyx_mstate_global->__pyx_codeobj_tab[25] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_AddEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_6_Bd_1_a_1_6_Bd_1_a_1_Kq_L_7_W, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[25])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 206}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[24] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K4Search, __pyx_mstate->__pyx_kp_b_iso88591_A_1D_Cq_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[24])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 233}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_e}; - __pyx_mstate_global->__pyx_codeobj_tab[26] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DeleteEdge, __pyx_mstate->__pyx_kp_b_iso88591_A_4t_Qa_a_8_at_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[26])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 210}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_infile_name, __pyx_mstate->__pyx_n_u_encoded, __pyx_mstate->__pyx_n_u_FileName}; + __pyx_mstate_global->__pyx_codeobj_tab[25] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Read, __pyx_mstate->__pyx_kp_b_iso88591_A_q_A_HAT_Zs_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[25])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 241}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[27] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_Planarity, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[27])) goto bad; + const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 218}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_outfile_name, __pyx_mstate->__pyx_n_u_mode, __pyx_mstate->__pyx_n_u_mode_code, __pyx_mstate->__pyx_n_u_encoded, __pyx_mstate->__pyx_n_u_theFileName}; + __pyx_mstate_global->__pyx_codeobj_tab[26] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Write, __pyx_mstate->__pyx_kp_b_iso88591_A_Y_0_S_E_A_m5_1_4q_A_31A_q_IQd, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[26])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 245}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 238}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[28] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_DrawPlanar, __pyx_mstate->__pyx_kp_b_iso88591_A_Qd_c_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[28])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[27] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_DrawPlanar, __pyx_mstate->__pyx_kp_b_iso88591_A_Qd_c_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[27])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 249}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 242}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_outfile_name, __pyx_mstate->__pyx_n_u_encoded, __pyx_mstate->__pyx_n_u_theFileName}; - __pyx_mstate_global->__pyx_codeobj_tab[29] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DrawPlanar_RenderToFile, __pyx_mstate->__pyx_kp_b_iso88591_A_q_q_L_SPQ_a_EQa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[29])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[28] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DrawPlanar_RenderToFile, __pyx_mstate->__pyx_kp_b_iso88591_A_q_q_L_SPQ_a_EQa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[28])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 257}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 250}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_renditionString, __pyx_mstate->__pyx_n_u_string_conversion_error}; - __pyx_mstate_global->__pyx_codeobj_tab[30] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DrawPlanar_RenderToString, __pyx_mstate->__pyx_kp_b_iso88591_A_Q_1_l_CTTWWX_aq_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[30])) goto bad; - } - { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 271}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[31] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_Outerplanarity, __pyx_mstate->__pyx_kp_b_iso88591_A_1_l_Q_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[31])) goto bad; - } - { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 275}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[32] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K23Search, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[32])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[29] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_DrawPlanar_RenderToString, __pyx_mstate->__pyx_kp_b_iso88591_A_Q_1_l_CTTWWX_aq_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[29])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 279}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 264}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[33] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K33Search, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[33])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[30] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_Outerplanarity, __pyx_mstate->__pyx_kp_b_iso88591_A_1_l_Q_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[30])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 283}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 268}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[34] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_K4Search, __pyx_mstate->__pyx_kp_b_iso88591_A_1D_Cq_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[34])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[31] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_ExtendWith_Planarity, __pyx_mstate->__pyx_kp_b_iso88591_A_AT_S_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[31])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 287}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 272}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_embedFlags, __pyx_mstate->__pyx_n_u_embed_result}; - __pyx_mstate_global->__pyx_codeobj_tab[35] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Embed, __pyx_mstate->__pyx_kp_b_iso88591_l_3d_s_aq_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[35])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[32] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_Embed, __pyx_mstate->__pyx_kp_b_iso88591_l_3d_s_aq_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[32])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 294}; + const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 279}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_copy_of_orig_graph, __pyx_mstate->__pyx_n_u_embed_result, __pyx_mstate->__pyx_n_u_check_result}; - __pyx_mstate_global->__pyx_codeobj_tab[36] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_TestEmbedResultIntegrity, __pyx_mstate->__pyx_kp_b_iso88591_YYZ_A_L_2_a_3d_s_aq_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[36])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[33] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_TestEmbedResultIntegrity, __pyx_mstate->__pyx_kp_b_iso88591_YYZ_A_L_2_a_3d_s_aq_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[33])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[37] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[37])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[34] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[34])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; - __pyx_mstate_global->__pyx_codeobj_tab[38] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[38])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[35] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[35])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 289}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_encoded_version}; + __pyx_mstate_global->__pyx_codeobj_tab[36] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetProjectVersionFull, __pyx_mstate->__pyx_kp_b_iso88591_C1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[36])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 294}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_encoded_version}; + __pyx_mstate_global->__pyx_codeobj_tab[37] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_planarity_full_graph_pyx, __pyx_mstate->__pyx_n_u_gp_GetLibPlanarityVersionFull, __pyx_mstate->__pyx_kp_b_iso88591_H, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[37])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; @@ -12275,33 +12077,6 @@ CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, Py #endif #endif -/* decode_c_bytes (used by decode_bytes) */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( - const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - if (unlikely((start < 0) | (stop < 0))) { - if (start < 0) { - start += length; - if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - } - if (stop > length) - stop = length; - if (unlikely(stop <= start)) - return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode); - length = stop - start; - cstring += start; - if (decode_func) { - return decode_func(cstring, length, errors); - } else { - return PyUnicode_Decode(cstring, length, encoding, errors); - } -} - /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, @@ -13275,39 +13050,168 @@ static int __Pyx_ParseKeywordsTuple( #endif return -1; } - -/* ParseKeywords */ -static int __Pyx_ParseKeywords( - PyObject *kwds, - PyObject * const *kwvalues, - PyObject ** const argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - Py_ssize_t num_kwargs, - const char* function_name, - int ignore_unknown_kwargs) -{ - if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) - return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); - else if (kwds2) - return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); - else - return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); + +/* ParseKeywords */ +static int __Pyx_ParseKeywords( + PyObject *kwds, + PyObject * const *kwvalues, + PyObject ** const argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + Py_ssize_t num_kwargs, + const char* function_name, + int ignore_unknown_kwargs) +{ + if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) + return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); + else if (kwds2) + return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); + else + return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); +} + +/* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); + for (i=0; i= 0x030C00A6 + PyObject *current_exception = tstate->current_exception; + if (unlikely(!current_exception)) return 0; + exc_type = (PyObject*) Py_TYPE(current_exception); + if (exc_type == err) return 1; +#else + exc_type = tstate->curexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; +#endif + #if CYTHON_AVOID_BORROWED_REFS + Py_INCREF(exc_type); + #endif + if (unlikely(PyTuple_Check(err))) { + result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + } else { + result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); + } + #if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(exc_type); + #endif + return result; +} +#endif + +/* PyObjectGetAttrStrNoError (used by GetBuiltinName) */ +#if __PYX_LIMITED_VERSION_HEX < 0x030d0000 +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} +#endif +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 + (void) PyObject_GetOptionalAttr(obj, attr_name, &result); + return result; +#else +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +#endif +} + +/* GetBuiltinName (used by GetModuleGlobalName) */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name); + if (unlikely(!result) && !PyErr_Occurred()) { + PyErr_Format(PyExc_NameError, + "name '%U' is not defined", name); + } + return result; +} + +/* PyDictVersioning (used by GetModuleGlobalName) */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); } +#endif -/* PyObjectFastCallMethod */ -#if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000 -static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) { +/* GetModuleGlobalName */ +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ PyObject *result; - PyObject *attr = PyObject_GetAttr(args[0], name); - if (unlikely(!attr)) +#if CYTHON_COMPILING_IN_LIMITED_API + if (unlikely(!__pyx_m)) { + if (!PyErr_Occurred()) + PyErr_SetNone(PyExc_NameError); return NULL; - result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1); - Py_DECREF(attr); - return result; -} + } + result = PyObject_GetAttr(__pyx_m, name); + if (likely(result)) { + return result; + } + PyErr_Clear(); +#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS + if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear(); + __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return result; + } +#else + result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); #endif + return __Pyx_GetBuiltinName(name); +} /* CIntToDigits (used by CIntToPyUnicode) */ static const char DIGIT_PAIRS_10[2*10*10+1] = { @@ -13671,148 +13575,6 @@ static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const cha return -1; } -/* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */ -#if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); - for (i=0; i= 0x030C00A6 - PyObject *current_exception = tstate->current_exception; - if (unlikely(!current_exception)) return 0; - exc_type = (PyObject*) Py_TYPE(current_exception); - if (exc_type == err) return 1; -#else - exc_type = tstate->curexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; -#endif - #if CYTHON_AVOID_BORROWED_REFS - Py_INCREF(exc_type); - #endif - if (unlikely(PyTuple_Check(err))) { - result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - } else { - result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); - } - #if CYTHON_AVOID_BORROWED_REFS - Py_DECREF(exc_type); - #endif - return result; -} -#endif - -/* PyObjectGetAttrStrNoError (used by GetBuiltinName) */ -#if __PYX_LIMITED_VERSION_HEX < 0x030d0000 -static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) - __Pyx_PyErr_Clear(); -} -#endif -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { - PyObject *result; -#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 - (void) PyObject_GetOptionalAttr(obj, attr_name, &result); - return result; -#else -#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { - return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); - } -#endif - result = __Pyx_PyObject_GetAttrStr(obj, attr_name); - if (unlikely(!result)) { - __Pyx_PyObject_GetAttrStr_ClearAttributeError(); - } - return result; -#endif -} - -/* GetBuiltinName (used by GetModuleGlobalName) */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name); - if (unlikely(!result) && !PyErr_Occurred()) { - PyErr_Format(PyExc_NameError, - "name '%U' is not defined", name); - } - return result; -} - -/* PyDictVersioning (used by GetModuleGlobalName) */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ -#if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if CYTHON_COMPILING_IN_LIMITED_API - if (unlikely(!__pyx_m)) { - if (!PyErr_Occurred()) - PyErr_SetNone(PyExc_NameError); - return NULL; - } - result = PyObject_GetAttr(__pyx_m, name); - if (likely(result)) { - return result; - } - PyErr_Clear(); -#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS - if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear(); - __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return result; - } -#else - result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - /* ArgTypeTestFunc (used by ArgTypeTest) */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { @@ -13861,6 +13623,19 @@ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *nam return 0; } +/* PyObjectFastCallMethod */ +#if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000 +static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) { + PyObject *result; + PyObject *attr = PyObject_GetAttr(args[0], name); + if (unlikely(!attr)) + return NULL; + result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1); + Py_DECREF(attr); + return result; +} +#endif + /* PyLongCompare */ static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) { CYTHON_MAYBE_UNUSED_VAR(intval); @@ -14201,6 +13976,33 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( } } +/* decode_c_bytes (used by decode_bytes) */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + if (unlikely((start < 0) | (stop < 0))) { + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (stop > length) + stop = length; + if (unlikely(stop <= start)) + return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode); + length = stop - start; + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + /* AllocateExtensionType */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) { if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { diff --git a/planarity/full/graph.pyx b/planarity/full/graph.pyx index a9cb3a6..07b5a9d 100644 --- a/planarity/full/graph.pyx +++ b/planarity/full/graph.pyx @@ -13,6 +13,7 @@ from planarity.full cimport cappconst from planarity.full cimport cgraphLib OK = cappconst.OK +AT_EDGE_CAPACITY_LIMIT = cgraphLib.AT_EDGE_CAPACITY_LIMIT NONEMBEDDABLE = cgraphLib.NONEMBEDDABLE NOTOK = cappconst.NOTOK NIL = cappconst.NIL @@ -25,16 +26,6 @@ EMBEDFLAGS_SEARCHFORK33 = cgraphLib.EMBEDFLAGS_SEARCHFORK33 EMBEDFLAGS_SEARCHFORK4 = cgraphLib.EMBEDFLAGS_SEARCHFORK4 -def gp_GetProjectVersionFull(): - cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() - return encoded_version.decode('utf-8') - - -def gp_GetLibPlanarityVersionFull(): - cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() - return encoded_version.decode('utf-8') - - cdef class Graph: def __cinit__(self): global global_id_count @@ -46,72 +37,21 @@ cdef class Graph: if self._theGraph != NULL: cgraphLib.gp_Free(&self._theGraph) - def gp_IsEdge(self, int e): - return ( - (e >= self.gp_EdgeArrayStart()) and - (e < self.gp_EdgeArraySize()) and - cgraphLib.gp_IsEdge(self._theGraph, e) - ) - - def gp_EdgeArrayStart(self): - return cgraphLib.gp_EdgeArrayStart(self._theGraph) - - def gp_EdgeInUse(self, int e): - if not self.gp_IsEdge(e): - raise RuntimeError( - f"gp_EdgeInUse() failed: invalid edge index '{e}'." - ) - - return cgraphLib.gp_EdgeInUse(self._theGraph, e) - - def gp_EdgeArraySize(self): - return cgraphLib.gp_EdgeArraySize(self._theGraph) - - def gp_EdgeInUseArraySize(self): - return cgraphLib.gp_EdgeInUseArraySize(self._theGraph) - - def gp_GetFirstEdge(self, int v): - if not self.gp_IsVertex(v): - raise RuntimeError( - f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." - ) - - return cgraphLib.gp_GetFirstEdge(self._theGraph, v) - - def gp_GetNextEdge(self, int e): - if not self.gp_IsEdge(e): - raise RuntimeError( - f"gp_GetNextEdge() failed: invalid edge index '{e}'." - ) + def gp_InitGraph(self, int n): + if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: + raise RuntimeError(f"gp_InitGraph() failed.") - return cgraphLib.gp_GetNextEdge(self._theGraph, e) + def gp_ReinitGraph(self): + cgraphLib.gp_ReinitGraph(self._theGraph) - def gp_GetNeighbor(self, int e): - if not self.gp_IsEdge(e): + def gp_EnsureEdgeCapacity(self, int new_edge_capacity): + if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: raise RuntimeError( - f"gp_GetNeighbor() failed: invalid edge index '{e}'." - ) - - return cgraphLib.gp_GetNeighbor(self._theGraph, e) - - def gp_IsVertex(self, int v): - return ( - (v >= self.gp_GetFirstVertex()) and - (v <= self.gp_GetLastVertex()) and - cgraphLib.gp_IsVertex(self._theGraph, v) - ) - - def gp_GetFirstVertex(self): - return cgraphLib.gp_GetFirstVertex(self._theGraph) - - def gp_GetLastVertex(self): - return cgraphLib.gp_GetLastVertex(self._theGraph) + "gp_EnsureEdgeCapacity() failed to set edge capacity to " + f"{new_edge_capacity}.") - def gp_VertexInRangeAscending(self, int v): - return ( - v >= self.gp_GetFirstVertex() and - cgraphLib.gp_VertexInRangeAscending(self._theGraph, v) - ) + def gp_GetEdgeCapacity(self): + return cgraphLib.gp_GetEdgeCapacity(self._theGraph) def gp_GetN(self)-> int: """ @@ -122,13 +62,6 @@ cdef class Graph: return cgraphLib.gp_GetN(self._theGraph) - def gp_InitGraph(self, int n): - if cgraphLib.gp_InitGraph(self._theGraph, n) != OK: - raise RuntimeError(f"gp_InitGraph() failed.") - - def gp_ReinitializeGraph(self): - cgraphLib.gp_ReinitializeGraph(self._theGraph) - def gp_CopyGraph(self, Graph src_graph): # NOTE: this is interpreting the self as the dstGraph, i.e. copying # the Graph wrapper that is passed in as the srcGraph @@ -164,34 +97,6 @@ cdef class Graph: return new_graph - def gp_Read(self, str infile_name): - # Convert Python str to UTF-8 encoded bytes, and then to const char * - cdef bytes encoded = infile_name.encode('utf-8') - cdef const char *FileName = encoded - - if cgraphLib.gp_Read(self._theGraph, FileName) != OK: - raise RuntimeError(f"gp_Read() failed.") - - def gp_Write(self, str outfile_name, str mode): - mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" - else (cgraphLib.WRITE_ADJMATRIX if mode == "m" - else (cgraphLib.WRITE_G6 if mode == "g" - else None))) - if not mode_code: - raise ValueError( - f"Invalid graph format specifier \"{mode}\" is not one of " - "'gam'." - ) - - # Convert Python str to UTF-8 encoded bytes, and then to const char * - cdef bytes encoded = outfile_name.encode('utf-8') - cdef const char *theFileName = encoded - - if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: - raise RuntimeError( - f"gp_Write() of graph to '{outfile_name}' failed." - ) - def gp_FindEdge(self, int u, int v): if not self.gp_IsVertex(u): raise RuntimeError(f"'{u}' is not a valid vertex label.") @@ -206,15 +111,6 @@ cdef class Graph: return cgraphLib.gp_GetVertexDegree(self._theGraph, v) - def gp_GetEdgeCapacity(self): - return cgraphLib.gp_GetEdgeCapacity(self._theGraph) - - def gp_EnsureEdgeCapacity(self, int new_edge_capacity): - if cgraphLib.gp_EnsureEdgeCapacity(self._theGraph, new_edge_capacity) != OK: - raise RuntimeError( - "gp_EnsureEdgeCapacity() failed to set edge capacity to " - f"{new_edge_capacity}.") - def gp_AddEdge(self, int u, int ulink, int v, int vlink): if ulink != 0 and ulink != 1: raise RuntimeError( @@ -238,10 +134,107 @@ cdef class Graph: return cgraphLib.gp_DeleteEdge(self._theGraph, e) - def gp_ExtendWith_Planarity(self): - if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: - raise RuntimeError("Failed to extend graph with Planarity structures.") + def gp_LowerBoundEdgeStorage(self): + return cgraphLib.gp_LowerBoundEdgeStorage(self._theGraph) + def gp_UpperBoundEdgeStorage(self): + return cgraphLib.gp_UpperBoundEdgeStorage(self._theGraph) + + def gp_IsEdge(self, int e): + return ( + (e >= self.gp_LowerBoundEdgeStorage()) and + (e < self.gp_UpperBoundEdgeStorage()) and + cgraphLib.gp_IsEdge(self._theGraph, e) + ) + + def gp_EdgeInUse(self, int e): + if not self.gp_IsEdge(e): + raise RuntimeError( + f"gp_EdgeInUse() failed: invalid edge index '{e}'." + ) + + return cgraphLib.gp_EdgeInUse(self._theGraph, e) + + def gp_UpperBoundEdges(self): + return cgraphLib.gp_UpperBoundEdges(self._theGraph) + + def gp_GetNextEdge(self, int e): + if not self.gp_IsEdge(e): + raise RuntimeError( + f"gp_GetNextEdge() failed: invalid edge index '{e}'." + ) + + return cgraphLib.gp_GetNextEdge(self._theGraph, e) + + def gp_GetNeighbor(self, int e): + if not self.gp_IsEdge(e): + raise RuntimeError( + f"gp_GetNeighbor() failed: invalid edge index '{e}'." + ) + + return cgraphLib.gp_GetNeighbor(self._theGraph, e) + + def gp_GetFirstEdge(self, int v): + if not self.gp_IsVertex(v): + raise RuntimeError( + f"gp_GetFirstEdge() failed: invalid vertex intex '{v}'." + ) + + return cgraphLib.gp_GetFirstEdge(self._theGraph, v) + + def gp_LowerBoundVertices(self): + return cgraphLib.gp_LowerBoundVertices(self._theGraph) + + def gp_UpperBoundVertices(self): + return cgraphLib.gp_UpperBoundVertices(self._theGraph) + + def gp_IsVertex(self, int v): + return ( + (v >= self.gp_LowerBoundVertices()) and + (v < self.gp_UpperBoundVertices()) and + cgraphLib.gp_IsVertex(self._theGraph, v) + ) + + def gp_ExtendWith_K23Search(self): + if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: + raise RuntimeError("Failed to extend graph with K23Search structures.") + + def gp_ExtendWith_K33Search(self): + if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: + raise RuntimeError("Failed to extend graph with K33Search structures.") + + def gp_ExtendWith_K4Search(self): + if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: + raise RuntimeError("Failed to extend graph with K4Search structures.") + + def gp_Read(self, str infile_name): + # Convert Python str to UTF-8 encoded bytes, and then to const char * + cdef bytes encoded = infile_name.encode('utf-8') + cdef const char *FileName = encoded + + if cgraphLib.gp_Read(self._theGraph, FileName) != OK: + raise RuntimeError(f"gp_Read() failed.") + + def gp_Write(self, str outfile_name, str mode): + mode_code = (cgraphLib.WRITE_ADJLIST if mode == "a" + else (cgraphLib.WRITE_ADJMATRIX if mode == "m" + else (cgraphLib.WRITE_G6 if mode == "g" + else None))) + if not mode_code: + raise ValueError( + f"Invalid graph format specifier \"{mode}\" is not one of " + "'gam'." + ) + + # Convert Python str to UTF-8 encoded bytes, and then to const char * + cdef bytes encoded = outfile_name.encode('utf-8') + cdef const char *theFileName = encoded + + if cgraphLib.gp_Write(self._theGraph, theFileName, mode_code) != OK: + raise RuntimeError( + f"gp_Write() of graph to '{outfile_name}' failed." + ) + def gp_ExtendWith_DrawPlanar(self): if cgraphLib.gp_ExtendWith_DrawPlanar(self._theGraph) != OK: raise RuntimeError("Failed to extend graph with DrawPlanar structures.") @@ -271,19 +264,11 @@ cdef class Graph: def gp_ExtendWith_Outerplanarity(self): if cgraphLib.gp_ExtendWith_Outerplanarity(self._theGraph) != OK: raise RuntimeError("Failed to extend graph with Outerplanarity structures.") + + def gp_ExtendWith_Planarity(self): + if cgraphLib.gp_ExtendWith_Planarity(self._theGraph) != OK: + raise RuntimeError("Failed to extend graph with Planarity structures.") - def gp_ExtendWith_K23Search(self): - if cgraphLib.gp_ExtendWith_K23Search(self._theGraph) != OK: - raise RuntimeError("Failed to extend graph with K23Search structures.") - - def gp_ExtendWith_K33Search(self): - if cgraphLib.gp_ExtendWith_K33Search(self._theGraph) != OK: - raise RuntimeError("Failed to extend graph with K33Search structures.") - - def gp_ExtendWith_K4Search(self): - if cgraphLib.gp_ExtendWith_K4Search(self._theGraph) != OK: - raise RuntimeError("Failed to extend graph with K4Search structures.") - def gp_Embed(self, int embedFlags) -> int: embed_result = cgraphLib.gp_Embed(self._theGraph, embedFlags) if embed_result != OK and embed_result != NONEMBEDDABLE: @@ -299,3 +284,13 @@ cdef class Graph: raise RuntimeError("Failed embed integrity check.") return check_result + + +def gp_GetProjectVersionFull(): + cdef bytes encoded_version = cgraphLib.gp_GetProjectVersionFull() + return encoded_version.decode('utf-8') + + +def gp_GetLibPlanarityVersionFull(): + cdef bytes encoded_version = cgraphLib.gp_GetLibPlanarityVersionFull() + return encoded_version.decode('utf-8')