Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
updated spkg-install (make -> make install), removed class Treedecomp…
Browse files Browse the repository at this point in the history
…osition (-> g.name())
  • Loading branch information
Lukas Larisch committed Nov 1, 2015
1 parent e968b23 commit 02c1abc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
24 changes: 10 additions & 14 deletions build/pkgs/tdlib/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ cp sage_tdlib.hpp src/src/

cd src

./configure --prefix="$SAGE_LOCAL" && $MAKE
./configure \
--prefix="$SAGE_LOCAL" \
--libdir="$SAGE_LOCAL/lib" \
--enable-shared --disable-static

$MAKE
if [ $? -ne 0 ]; then
echo >&2 "Failed to compile tdlib"
echo "Error building tdlib"
exit 1
fi

rm -rf "$SAGE_LOCAL/include/tdlib/"
mkdir "$SAGE_LOCAL/include/tdlib/"
cp src/sage_tdlib.hpp "$SAGE_LOCAL/include/tdlib/"

if [ "$UNAME" = "Darwin" ]; then
cp -f ./.libs/libtd.dylib "$SAGE_LOCAL/lib/libtd.dylib"
elif [ "$UNAME" = "CYGWIN" ]; then
cp -f ./.libs/libtd.so "$SAGE_LOCAL/lib/libtd.dll"
$MAKE install -j1
if [ $? -ne 0 ]; then
echo "Error installing tdlib"
exit 1
fi

# Copy this in all cases, in any case it doesn't hurt.
cp -f ./.libs/libtd.so "$SAGE_LOCAL/lib/libtd.so"
cp -f ./.libs/libtd.so.0 "$SAGE_LOCAL/lib/libtd.so.0"
27 changes: 10 additions & 17 deletions src/sage/graphs/graph_decompositions/tdlib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ include 'sage/ext/stdsage.pxi'


#!!!!!! NOTICE !!!!!!!!
#Sage vertices have to be named by unsigned integers
#Sage bags of decompositions have to be lists of unsigned integers
#For a graph G, G.vertices() must return a list of unsigned integers
#!!!!!!!!!!!!!!!!!!!!!!!!!!

##############################################################
############ GRAPH/DECOMPOSITION ENCODING/DECODING ###########
#the following will be used implicitly do the translation
#between Sage graph encoding and TdLib graph encoding,
#which is based on BGL

class TreeDecomposition(Graph):
#This is just for the repr-message.

def __repr__(self):
return "Treedecomposition of width " + str(get_width(self)) + " on " + str(self.order()) + " vertices"
#between Sage graph encoding and BGL graph encoding.

cdef make_tdlib_graph(G, vector[unsigned int] &V, vector[unsigned int] &E):
for v in G.vertices():
Expand Down Expand Up @@ -145,17 +137,17 @@ def treedecomposition_exact(G, lb=-1):
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
sage: G = graphs.HouseGraph()
sage: T = tdlib.treedecomposition_exact(G)
tree decomposition of width 2 computed
Tree decomposition of width 2 computed
sage: T.show(vertex_size=2000)
TEST::
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
sage: G = graphs.HouseGraph()
sage: T = tdlib.treedecomposition_exact(G)
tree decomposition of width 2 computed
Tree decomposition of width 2 computed
sage: G = graphs.PetersenGraph()
sage: T = tdlib.treedecomposition_exact(G)
tree decomposition of width 4 computed
Tree decomposition of width 4 computed
"""
cdef vector[unsigned int] V_G, E_G, E_T
cdef vector[vector[int]] V_T
Expand All @@ -170,10 +162,11 @@ def treedecomposition_exact(G, lb=-1):

sig_off()

T = TreeDecomposition()
T = Graph()
T.name("Tree decomposition")
make_sage_decomp(T, V_T, E_T)

print("tree decomposition of width " + str(get_width(T)) + " computed")
print("Tree decomposition of width " + str(get_width(T)) + " computed")

return T

Expand All @@ -193,10 +186,10 @@ def get_width(T):
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
sage: G = graphs.PetersenGraph()
sage: T = tdlib.treedecomposition_exact(G)
tree decomposition of width 4 computed
Tree decomposition of width 4 computed
sage: tdlib.get_width(T)
4
"""

return max(len(x) for x in T)-1
return max(len(x) for x in T)-1 if len(T) > 0 else -1

0 comments on commit 02c1abc

Please sign in to comment.