Help:=proc() if args=NULL then print(`functions provided by this package are:`): print(`computepoly(G0,G1,p,a,b)`): print(`PolyDiff(G0,p,a,b,c)`): print(`bunk(G0,a,b)`): print(`trim(G0,a,b,S)`): print(`PolyDiffC(G0,p,a,b,n,m,S)`): print(`Call Help on the name of one of these function names`): print(`to get a more specific description and example(s)`): elif (args[1]=computepoly) then print(`computes the probability that you can get from a to b with probability p`): print(`G0 and G1 are initially identical copies of the same graph`): print(`they must be deep copies as obtained from the function CopyGraph`): print(`not just references to the same graph`): print(`for example, try computepoly(Graph({{1,2},{2,3}}),Graph({{1,2},{2,3}}),p,1,3)`): print(`that is the probability that you can travel along the path of length two with two vertices removed`): print(`or, more interestingly computepoly(CompleteGraph(4),CompleteGraph(4),p,1,2)`): print(`which is the likelyhood you can get between any two particular vertices in K_4`): elif (args[1]=PolyDiff) then print(`given a graph G0, and edges removed with probability p, computes the differences`): print(`in probabilities between there being a path a to b minus there being a path a to c`): print(`for example:`): print(`PolyDiff(Graph({{1,2},{2,3},{2,b},{a,b},{b,c}}),p,1,3,c);`): elif(arfs[1] = bunk) then print(` takes a graph G0 assumed to be on the vertices a[1],...,a[N].`): print(` a, b are just symbols. returns the bunkbed graph where the mirrored version is on vertices b`): print(`For example calling:`): print(`bunk(CompleteGraph(4),a,b);`): print(`returns K_4 cartesian product with K_2`): print(`where one half is a[1],...,a[4] and the other half is b[1],...,b[4]`): elif(args[1] = trim) then print(`takes a bunkbed graph G0 where one side is a[1]...a[N]`): print(`and the other side is b[1],...,b[n] and a subset S of [N]`): print(`and removes the edges from a[i] to b[i] for each i in S`): print(`for example try:`): print(`trim(bunk(RelabelVertices(CompleteGraph(4),[a[1],a[2],a[3],a[4]]) ,a,b),a,b,{2,3});`): elif(args[1] = PolyDiffC) then print(`takes a bunkbed graph G0 whose vertices are a[1],...,a[N] and b[1],...b[N]`): print(`retains exactly those edges going between copies given in S`): print(`m and n are integers at most the number of vertices`): print(`computes the difference in probabilities that a[n] is connected to a[m] and`): print(`that a[n] is connected to b[m] after edges within each copy are removed with probability p independently`): print(`for example try:`): print(`PolyDiffC(Graph({{1,2},{2,3},{2,4}}),p,a,b,1,3,{4});`): fi: end: #computes the probability that you can get from a to b with probability p #G0 and G1 are initially identical copies of the same graph #they must be deep copies as obtained from the function CopyGraph #not just references to the same graph computepoly:=proc(G0,G1,p,a,b) local E,e,p0,p1: try ShortestPath(G1,a,b) catch : RETURN(0): end try; if(nops(Edges(G0))<1) then RETURN(1): fi: E:= Edges(G0): e := E[1]: DeleteEdge(G0,e): p0 := p*computepoly(G0,G1,p,a,b): DeleteEdge(G1,e): p1 :=(1-p)*computepoly(G0,G1,p,a,b): AddEdge(G0,e): AddEdge(G1,e): RETURN(factor(p1+p0)): end: #computes the differences in the probabilities of getting from a to b and frmo a to c #where edges are retained with probability p PolyDiff:=proc(G0,p,a,b,c) local G1: G1:=CopyGraph(G0): RETURN(factor(computepoly(G0,G1,p,a,b)-computepoly(G0,G1,p,a,c))): end: PolyDiffC:= proc(G0,p,a,b,n,m,S) local i,G1,G2: G1:=bunk(RelabelVertices(G0,[seq(a[i],i=1..nops(Vertices(G0)))]),a,b): G2:=CopyGraph(G1): trim(G1,a,b,{op(Vertices(G0))}): trim(G2,a,b,{op(Vertices(G0))} minus S): #print(Edges(G1)): #print(Edges(G2)): RETURN(factor(computepoly(G1,G2,p,a[n],a[m])-computepoly(G1,G2,p,a[n],b[m]))): end: #G0 is a graph on vertices a[i], bunked copy will be on vertices b[i] bunk:=proc(G0,a,b) local G1,i: G1:= CopyGraph(G0): G1:= RelabelVertices(G1,[seq(b[i],i=1..nops(Vertices(G1)))]): G1:=GraphUnion(G0,G1): for i from 1 to nops(Vertices(G0)) do AddEdge(G1,{a[i],b[i]}): od: G1: end: #takes the bunkbedgraph G on left vertices a and right vertices b and then removes the outside edges with indices in S trim:=proc(G0,a,b,S) local i: for i in S do: DeleteEdge(G0,{a[i],b[i]}): od: G0: end: