Magma functions and procedures contained in the file wgraphs.m:
      WGtable2WG
      Partition2WGtable
      WGelement2WGtable
      WGidealgens2WGtable
      TestWG
      MijA
      Mij2EltRootTable
      InduceWGtable
      InduceWG
      WG2HeckeRep
      TestHeckeRep
      PrintWG

In these names "WG" stands for W-graph. Given a Coxeter
system (W,S), a W-graph is a (directed or undirected) graph
with vertex labels and edge weights. The label attached to
a vertex v is a subset of S (called the descent set of v)
and the edge weights are scalars (usually integers). A W-graph
must determine a representation of the Hecke algebra H = H<q> of
the associated Coxeter system. The vertices of the W-graph can
be identified with basis elements of the representation space,
and by the conventions adopted here the action of the generator
T_s of H associated with an element s of S on a basis element v
is given by
  T_s*v = (-q^{-1})*v   if s is in the descent set of v,
  T_s*v = q*v + Sum(m*u) if s is not in the descent set of v,
where Sum indicates the sum over all edges with terminal vertex
equal to v for which s is in the descent set of the initial
vertex u, and m is the weight of the edge.

For the Coxeter group calculations involved in these functions
we need to know how the generators s in S act on the set of
elementary roots (see B. Brink, "The set of dominance minimal
roots", J. Algebra 206 (1998), no. 2, 371--412). Magma has a
built-in function "ReflectionTable" that provides the necessary
information. Specifically, let W be a finitely presented Coxeter
group with N elementary roots (numbered from 1 to N) and r
simple reflections (numbered 1 to r). If we define
  eltroots:=ReflectionTable(W)
then for i in {1 .. r} and j in {1 .. N},
  eltroots[i,j] = k
if the i-th simple reflection takes the j-th elementary root to
the k-th elementary root, or to a non-elementary root if k = 0,
or to a negative root if k < 0. (This last alternative occurs if
and only if j = i and k = -i.) Knowing the table eltroots makes
it quick and easy to do symbolic computation with elements of W,
represented as sequences of integers in {1 .. r} (corresponding
to words in S).

I found it convenient to use "mij-sequences" to specify Coxeter
groups. The mij-sequence consists of the on or below diagonal
entries in the Coxeter matrix. Thus if seq is the mij-sequence
and M the Coxeter matrix then
  M = SymmetricMatrix(seq)
and
  seq = &cat[[M[i,j] : j in [1..i]] : i in [1..Rank(W)]]
The function mijA applied to the integer n returns the
mij-sequence for type A_n (using the obvious numbering of the
Coxeter diagram).

The function Mij2EltRootTable takes as input the mij-sequence
and returns the elementary root action table. (In fact it is a
one-line function, returning
ReflectionTable(CoxeterGroup(GrpFPCox,SymmetricMatrix(seq)))
which is somewhat silly since internally ReflectionTable(W)
uses only the Coxeter matrix of W.)

The functions are mainly concerned with W-graph posets. The
motivating example for this concept is the set of all standard
tableaux corresponding to a given partition, the partial order
being dominance. By definition, if P is a W-graph poset then P
must be in one-to-one correspondence with a basis for an H-module
V (where H is the Hecke algebra associated with the given
Coxeter system). In the standard tableaux example, this module
is the Specht module; hence in the general case we refer to the
module V as GSM(P) (for generalized Specht module). For each
v in P the set S must be the disjoint union of two sets A(v) and
D(v), the ascents and descents of v. There must be a function
(s,v) --> sv from S x P to P such that the action of H on GSM(P)
satisfies the following rules (for all s in S and v in P):
  T_s*v = sv                   if sv > v,
  T_s*v = sv + (q-q^{-1})*v    if sv < v,
  T_s*v = -q^{-1}*v            if sv = v and s is in D(v),
  T_s*v = q*v + q*<earlier>    if sv = v and s is in A(v),
where <earlier> denotes a linear combination of {u in P | u < v}
with coefficients that are polynomials in q. For each s in
A(v) either sv = v or sv > v, and for each s in D(v) either
sv < v or sv = v. This (admittedly strange) definition is
motivated by the fact that Specht modules satisfy it. If v is
a standard tableau corresponding to a partion of n then a number
i in {1 .. n-1} is an ascent of v if i+1 is in a later column
of t than i, and is a descent of v if i+1 is in a lower row
of t than i. The fact that Specht modules satisfy the formulas
above is proved in the literature (e.g. Mathas' book), except
that in the "weak ascent" case (sv = v and s in A(v)) it is
not proved that the polynomial coefficients of {u in P | u < v}
are all divisible by q. The fact that they are is a theorem of
V. M. Nguyen (PhD thesis, University of Sydney, 2010). It turns
out that there is an algorithm by which a W-graph may be
constructed from a W-graph poset, the W-graph being uniquely
determined by the function (s,v) --> sv from S x P to P
and the descent/ascent sets. The polynomial coefficients in the
weak ascent case are not required. Of course the H-module
determined by the resulting W-graph is isomorphic to GSM(P).

In the magma functions, a W-graph poset P is represented by
a table with rows indexed by the integers in [1 .. Rank(W)]
and columns indexed by the integers in [1 .. #P]. If s is
the i-th element of S and v the j-th element of P then
table[i,j] = k if sv is the k-th element of P and sv is not
equal to v, while if sv = v then table[i,j] is either j or  -j
depending on whether s is in A(v) or D(v). The numbering of the
elements of P is chosen so that if v is the j-th element of P
and u is the k-th element then j < k whenever v < u. Hence
the descent set of the j-th element of P is
{ i : i in {1 .. #S} | table[i,j] < j }.

Given such a table as input, the function WGtable2WG outputs
the W-graph. Note that no further information about the
Coxeter system (W,S) or Hecke algebra H is needed for this
construction: the input table carries all the information that
is needed.

The procedure TestWG can be used to test whether a presumed
W-graph is indeed a W-graph. Two input values are required:
the W-graph and the mij-sequence of the relevant Coxeter system.
When applied to the W-graph produced by the WGtable2WG function,
this tests whether the input table did genuinely correspond to
a W-graph poset.

The function Partition2WGtable takes as its input a
nonincreasing sequence of positive integers (corresponding
to a partition) and returns the table corresponding to
the W-graph poset of standard tableaux of the given shape.
For example:
>  table:=Partition2WGtable([4,4,3,1]);
>  wg:=WGtable2WG(table);
>  TestWG(wg,mij_a(11));
which should cause the word "true" to be printed 66 times
(as the defining relations of H are checked).

Given a Coxeter system (W,S) and an element w in W, let P be
the set {x in W | length(wx^{-1}) = length(w) - length(x)},
considered as a poset under the Bruhat order on W. Given also a
subset J of {t in S | length(wt) > length(w)}, for each x in P
we define D(x) to be union of {s in S | length(sx) < length(x)}
{s in S | sx = xt for some t in J }. If P is now a W-graph poset
with the sets D(x) as the descent sets then we say that w is a
W-graph determining element relative to J. For example, suppose
that (W,S) is of type A_n, and given a partition of n+1 let let
t be the (unique) standard tableau whose column group is
generated by a subset of S. Let w be the maximal length element
such that the tableau wt is standard. Then w is a W-graph
determining element with respect to the set J consisting of
those s in S that are in the column stabilizer of t. Other
examples (for any Coxeter system with finite W) are provided by
the distinguished left coset representatives of maximal length
for standard parabolic subgroups W_K (where the set J may be
taken to be either K or the empty set).

The function WGelement2WGtable outputs the table corresponding
to the W-graph poset of a W-graph determining element. Three
input values are required, corresponding to the Coxeter system
(W,S), the W-graph determining element, and the subset J of S.
The first argument must be a sequence of integers from the set
{1 .. #S}, corresponding to a word representing the W-graph
determining element. The second argument should be a subset
of {1 .. #S} corresponding to a subset of S whose intersection
with {t in S | length(wt) > length(w)} is J. The third argument
should be the elementary roots action table for the Coxeter
system.
Example:
>  b5:=[1,4,1,2,3,1,2,2,3,1,2,2,2,3,1];
>  eltroots:=Mij2EltRootTable(b5)
>  table:=WGelement2WGtable([5,4,3,2,1,2,3,4,5],{},eltroots);
>  wg:=WGtable2WG(table);
>  TestWG(wg,b5);

The function DReps.m outputs the sequence of distinguished
coset representatives for a standard parabolic subgroup of
a Coxeter group. The input should be a set of integers
(e.g. {1,2,5} to indicate the subgroup generated by the first,
second and fifth simple reflections) and the elementary root
action table for the Coxeter group in question.
Example: 
> e8:=[1,3,1,2,3,1,2,3,2,1,2,2,2,3,1,2,2,3,2,2,1,2,2,2,2,2,3,1,2,2,2,2,2,2,3,1];
> era:=Mij2EltRootTable(e8);
> drs:=DReps({1..7},era);
> tab:=WGelement2WGtable(drs[201],{1..7},era);
> wg:=WGtable2WG(tab);
> TestWG(wg,e8);
(It happens that drs[201] is a W-graph determining element!)

The function WGidealgens2WGtable is just like WGelement2WGtable except
that it takes a set of generators as input rather than a single
generator.

The function InduceWGtable takes as input the table
corresponding to a W-graph poset for a Coxeter group that
can be embedded as a standard parabolic subgroup of W, and
returns the table corresponding to the induced W-graph poset.
More precisely, three input arguments are needed:
1) a sequence of distinct elements, the i-th term of which
specifies which generator of W is to be identified with the
i-th generator of the the embedded Coxeter group.
2) the table that is to be induced,
3) the elementary root action table for (W,S),
Example:
>  e6:=[1,3,1,2,3,1,2,3,2,1,2,2,2,3,1,2,2,3,2,2,1];
>  specht32:=Partition2WGtable([3,2]);
>  era:=Mij2EltRootTable(e6);
>  table:=InduceWGtable([1,2,4,5],specht32,era);
>  wg:=WGtable2WG(table);
>  TestWG(wg,e6);

The function InduceWG implements a variant of the construction
from the paper "Inducing W-graphs" of Howlett and Yin, according
to which a W-graph for a standard parabolic subgroup can be
induced to yield a W-graph for W itself. The three input arguments
are
1) the graph that is to be induced,
2) the elementary root action table for (W,S),
3) a sequence of distinct elements, the i-th term of which
specifies which generator of W is to be identified with the
i-th generator of the the embedded Coxeter group.

The function WG2HeckeRep takes as input a W-graph and an
integer n that should be the rank of the relevant Coxeter group,
and returns a sequence of n sparse matrices that satisfy the
defining relations of the Hecke algebra.

The procedure TestHeckeRep takes as input a sequence of
matrices (or sparse matrices) and an mij-sequence, and tests
whether the matrices satisfy the defining relations of the
Hecke algebra.

The function PrintWG can be used to print a W-graph to a file.
The resulting file will be in a form that can be loaded in
Magma.

The procedure mult is not really part of the W-graphs collection,
but may be useful. It modifies a sequence w that corresponds
to a ShortLex reduced word for an element of W by postmultiplying
by a simple reflection s. The elementary root action table is
required as an argument (since this specifies the structure
of W).