pseudoPython

Duncan Smith buzzard at urubu.freeserve.co.uk
Wed Mar 26 13:18:14 EST 2003


Hello,
         I'm in the process of writing a paper and I need to include some
pseudocode.  I'd really appreciate it if any pseudocode interpreters could
give me some feedback on the following.  eg. does it rely too heavily on the
interpreter knowing Python?  Obviously, fully understanding this would
require the text of the paper, but does it clear enough generally (given
that I'd add a bit about comments / line continuation / indenting code
blocks)?  Cheers.

updateConnections(Cv):

Cw = Cv's child
if Cw is null:
    return
add a tree edge from Cv to Cw's child
remove the edge between Cw and its child
remove the tree edge (Cv,Cw)
add the tree edge (Cw,Cv)

for each cluster C in Cv's parents:
    if C contains w:
        remove the tree edge (C,Cv)
        add the tree edge (C,Cw)


getVadj(Cv):

Cw = Cv's child
if Cw is null:
    return
Wadj = Cw\Cv
Vadj = Cw union Cv\{v,w}\Wadj  #initially Vadj union VWadj
for each cluster C in Cv's parents:
    if C contains w:
        Vadj = Vadj\C
for each node u in Vadj:
if u is a member of adj(w):
    Vadj = Vadj\{u}
return Vadj


permCluster(Cv):

Cw = Cv's child
if Cw is null:
    return
Vadj = getVadj(Cv)

# update the members
Cv=Cw union {v}\{w}
Cw=Cw union {v}\Vadj

# update the connections
updateConnections()


cliqueThin(clique):

# get the thinnable edges in some way (see text)
thinnableEdges = thinEdges(clique)

# initialise a list to hold new cliques
cliques = []

while there are thinnableEdges:
    Cv = the lowest ordered cluster for \
    which there exists a thinnableEdge \
    incident to v
    while Cv is not the child of clique:
        permCluster(parent of Cv)

    permCluster(clique)
    cliques.append(Cv)

    for each edge in thinnableEdges:
        if edge is incident to v:
            remove edge \
            from thinnableEdges
        elif edge is in Cv:
            remove edge \
            from thinnableEdges
return cliques






More information about the Python-list mailing list