Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ include planarity/c/LICENSE.TXT
include README.md
include planarity/c/README

include planarity/cplanarity.pxd
include planarity/planarity.c
include planarity/planarity.pyx
include planarity/classic/cplanarity.pxd
include planarity/classic/planarity.c
include planarity/classic/planarity.pyx

include planarity/full/cappconst.pxd
include planarity/full/cg6IterationDefs.pxd
include planarity/full/cgraphLib.pxd
include planarity/full/graph.c
include planarity/full/g6IterationUtils.c
include planarity/full/graph.pyx
include planarity/full/g6IterationUtils.pyx

recursive-include examples *.py *.gz
recursive-include doc *.py *.rst Makefile *.html *.txt
Expand Down
Empty file added planarity/__init__.pxd
Empty file.
30 changes: 26 additions & 4 deletions planarity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
from .planarity import PGraph
from .planarity_functions import *
from .planarity_networkx import *
from .classic.planarity import PGraph
from .classic.planarity_functions import *
from .classic.planarity_networkx import *

from .full.g6IterationUtils import G6ReadIterator, G6WriteIterator
from .full.graph import (
Graph,
OK,
NONEMBEDDABLE,
NOTOK,
NIL,
EMBEDFLAGS_PLANAR,
EMBEDFLAGS_DRAWPLANAR,
EMBEDFLAGS_OUTERPLANAR,
EMBEDFLAGS_SEARCHFORK23,
EMBEDFLAGS_SEARCHFORK33,
EMBEDFLAGS_SEARCHFORK4,
)
from .full.planarity_app_utils import (
PLANARITY_ALGORITHM_SPECIFIERS,
ENSURE_ARC_CAPACITY_SPECIFIERS,
attach_algorithm,
get_embed_flags,
max_num_edges_for_order,
)

# NOTE: In the future, we could automatically generate the version number by
# configuring setuptools-scm, but presently this seems simpler.
__version__ = "0.7.8"
__version__ = "0.7.10"
Empty file added planarity/classic/__init__.pxd
Empty file.
Empty file added planarity/classic/__init__.py
Empty file.
16 changes: 8 additions & 8 deletions planarity/cplanarity.pxd → planarity/classic/cplanarity.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Interface for Boyer's (C) planarity algorithms."""
cdef extern from "c/graphLib/graphStructures.h":
"""Interface for Boyer's (c) planarity algorithms."""
cdef extern from "../c/graphLib/graphStructures.h":
ctypedef struct baseGraphStructure:
pass
ctypedef baseGraphStructure * graphP
Expand All @@ -18,13 +18,13 @@ cdef extern from "c/graphLib/graphStructures.h":
cdef int gp_GetNextArc(graphP theGraph, int v)
cdef int gp_GetDirection(graphP theGraph, int v)

cdef extern from "c/graphLib/lowLevelUtils/appconst.h":
cdef extern from "../c/graphLib/lowLevelUtils/appconst.h":
cdef int OK, NOTOK, NULL

cdef extern from "c/graphLib/graph.h":
cdef extern from "../c/graphLib/graph.h":
cdef int WRITE_ADJLIST

cdef extern from "c/graphLib/graphStructures.h":
cdef extern from "../c/graphLib/graphStructures.h":
cdef int EMBEDFLAGS_PLANAR, NONEMBEDDABLE, EMBEDFLAGS_DRAWPLANAR
cdef int EDGEFLAG_DIRECTION_INONLY, EDGEFLAG_DIRECTION_OUTONLY

Expand All @@ -37,12 +37,12 @@ cdef extern from "c/graphLib/graphStructures.h":
cdef void gp_SortVertices(graphP theGraph)


cdef extern from "c/graphLib/planarityRelated/graphDrawPlanar.h":
cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.h":
cdef int gp_DrawPlanar_RenderToString(graphP theEmbedding, char **pRenditionString);
cdef int gp_AttachDrawPlanar(graphP theGraph)


cdef extern from "c/graphLib/planarityRelated/graphDrawPlanar.private.h":
cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.private.h":
ctypedef struct DrawPlanar_VertexInfo:
int pos
int start
Expand All @@ -59,6 +59,6 @@ cdef extern from "c/graphLib/planarityRelated/graphDrawPlanar.private.h":
DrawPlanar_EdgeRecP E
DrawPlanar_VertexInfoP VI

cdef extern from "c/graphLib/extensionSystem/graphExtensions.h":
cdef extern from "../c/graphLib/extensionSystem/graphExtensions.h":
cdef void * gp_GetExtension(graphP theGraph, int moduleID)
cdef int gp_FindExtension(graphP theGraph, int moduleID, void *pContext)
1,214 changes: 607 additions & 607 deletions planarity/planarity.c → planarity/classic/planarity.c

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions planarity/planarity.pyx → planarity/classic/planarity.pyx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!python
#cython: embedsignature=True
"""
Wrapper for Boyer's (C) planarity algorithms.
Wrapper for Boyer's (c) planarity algorithms.
"""
from planarity cimport cplanarity
from libc.stdlib cimport free
import warnings

from planarity.classic cimport cplanarity


cdef class PGraph:
cdef cplanarity.graphP theGraph
cdef dict nodemap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Functional interface to planarity."""
import planarity

__all__ = ['is_planar', 'kuratowski_edges', 'ascii', 'write', 'mapping']
__all__ = [
'is_planar',
'kuratowski_edges',
'ascii',
'write',
'mapping'
]

def is_planar(graph):
"""Test planarity of graph."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""NetworkX interface to planarity."""
import planarity

__all__ = ['kuratowski_subgraph', 'pgraph_graph',
'networkx_graph', 'draw']
__all__ = [
'kuratowski_subgraph',
'networkx_graph',
'pgraph_graph',
'draw',
]

def kuratowski_subgraph(graph):
"""Return forbidden subgraph of nonplanar graph G."""
Expand Down
Empty file added planarity/full/__init__.pxd
Empty file.
Empty file added planarity/full/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions planarity/full/cappconst.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""C-level interface for the Edge Addition Planarity Suite Graph Library

Specifically exposes contents from appconst.h.
"""

cdef extern from "../c/graphLib/lowLevelUtils/appconst.h":
cdef int OK, NOTOK, NULL, NIL, NIL_CHAR
35 changes: 35 additions & 0 deletions planarity/full/cg6IterationDefs.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""C-level interface for the Edge Addition Planarity Suite Graph Library

Specifically provides definitions for functions and macros that are required
to interact with .g6 graph files.
"""

from planarity.full.cgraphLib cimport graphP


cdef extern from "../c/graphLib/io/g6-read-iterator.h":
ctypedef struct G6ReadIterator:
pass
ctypedef G6ReadIterator * G6ReadIteratorP

bint contentsExhausted(G6ReadIteratorP)

int allocateG6ReadIterator(G6ReadIteratorP *, graphP)
int beginG6ReadIterationFromG6FilePath(G6ReadIteratorP, char *)

int readGraphUsingG6ReadIterator(G6ReadIteratorP)
int endG6ReadIteration(G6ReadIteratorP)
int freeG6ReadIterator(G6ReadIteratorP *)


cdef extern from "../c/graphLib/io/g6-write-iterator.h":
ctypedef struct G6WriteIterator:
pass
ctypedef G6WriteIterator * G6WriteIteratorP

int allocateG6WriteIterator(G6WriteIteratorP *, graphP)
int beginG6WriteIterationToG6FilePath(G6WriteIteratorP, char *)

int writeGraphUsingG6WriteIterator(G6WriteIteratorP)
int endG6WriteIteration(G6WriteIteratorP)
int freeG6WriteIterator(G6WriteIteratorP *)
78 changes: 78 additions & 0 deletions planarity/full/cgraphLib.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""C-level interface for the Edge Addition Planarity Suite Graph Library

Specifically provides definitions for functions and macros that are required
to interact with graphP structs.
"""

cdef extern from "../c/graphLib/graphStructures.h":
cdef int NONEMBEDDABLE

ctypedef struct baseGraphStructure:
pass
ctypedef baseGraphStructure * graphP

int gp_IsArc(int e)
int gp_GetFirstEdge(graphP theGraph)
int gp_EdgeInUse(graphP theGraph, int e)
int gp_EdgeIndexBound(graphP theGraph)
int gp_EdgeInUseIndexBound(graphP theGraph)
int gp_GetFirstArc(graphP theGraph, int v)
int gp_GetNextArc(graphP theGraph, int e)

int gp_GetNeighbor(graphP theGraph, int e)

int gp_IsVertex(int v)
int gp_GetFirstVertex(graphP theGraph)
int gp_GetLastVertex(graphP theGraph)
int gp_VertexInRange(graphP theGraph, int v)

int gp_getN(graphP theGraph)


cdef extern from "../c/graphLib/graph.h":
int EMBEDFLAGS_PLANAR, EMBEDFLAGS_DRAWPLANAR, EMBEDFLAGS_OUTERPLANAR
int EMBEDFLAGS_SEARCHFORK23, EMBEDFLAGS_SEARCHFORK33, EMBEDFLAGS_SEARCHFORK4

cdef int WRITE_ADJLIST, WRITE_ADJMATRIX, WRITE_G6

graphP gp_New()
int gp_InitGraph(graphP theGraph, int N)
void gp_ReinitializeGraph(graphP theGraph)
int gp_CopyGraph(graphP dstGraph, graphP srcGraph)
graphP gp_DupGraph(graphP theGraph);

void gp_Free(graphP *pGraph)

int gp_Read(graphP theGraph, char *FileName)
int gp_ReadFromString(graphP theGraph, char *inputStr)

int gp_Write(graphP theGraph, char *FileName, int Mode)
int gp_WriteToString(graphP theGraph, char **pOutputStr, int Mode)

int gp_GetNeighborEdgeRecord(graphP theGraph, int u, int v)
int gp_GetVertexDegree(graphP theGraph, int v)

int gp_GetArcCapacity(graphP theGraph)
int gp_EnsureArcCapacity(graphP theGraph, int requiredArcCapacity)

int gp_AddEdge(graphP theGraph, int u, int ulink, int v, int vlink)
int gp_DeleteEdge(graphP theGraph, int e, int nextLink)

int gp_Embed(graphP theGraph, int embedFlags)
int gp_TestEmbedResultIntegrity(graphP theGraph, graphP origGraph, int embedResult)


cdef extern from "../c/graphLib/planarityRelated/graphDrawPlanar.h":
int gp_AttachDrawPlanar(graphP theGraph)


cdef extern from "../c/graphLib/homeomorphSearch/graphK23Search.h":
int gp_AttachK23Search(graphP theGraph)


cdef extern from "../c/graphLib/homeomorphSearch/graphK33Search.h":
int gp_AttachK33Search(graphP theGraph)


cdef extern from "../c/graphLib/homeomorphSearch/graphK4Search.h":
int gp_AttachK4Search(graphP theGraph)
Loading