On Mon, May 18, 2015 at 7:51 AM, Vincent Delecroix
<20100.delecr...@gmail.com> wrote:
> Moreover, for non oriented graph the Sage definition does not fit with
> wikipedia... I opened the trac ticket
>
>     http://trac.sagemath.org/ticket/18440
>

Thank you.

In case it's of any interest, the code I've been using privately
allows for an arbitrary edge orientation (following Biggs). See below:

def incidence_value(Gamma, v, e, eo):
    """
    This computes the incidence value of a vertex and edge of
    a graph Gamma with edge-orientation vector eo.

    INPUT:
        Gamma - graph
        v  - vertex of Gamma
        e  - edge of Gamma
        eo - a vector of 1's and -1's whose length is the number of
edges in Gamma

    EXAMPLES:
        sage: Gamma = graphs.PaleyGraph(9)
        sage: E = Gamma.edges()
        sage: V = Gamma.vertices()
        sage: eo = [1]*len(E)
        sage: incidence_value(Gamma, V[2], E[3], eo)
        0
        sage: incidence_value(Gamma, V[8], E[3], eo)
        -1

    """
    E = Gamma.edges()
    if v in e:
        if v == e[0]:
            k = E.index(e)
            return eo[k]
        elif v == e[1]:
            k = E.index(e)
            return -eo[k]
        else:
            return 0
    return 0


def incidence_matrix(Gamma, eo):
    """
    This computes the incidence matrix (whose rows are indexed by edges
    and whose columns are indexed by vertices) of a graph Gamma with
    edge-orientation vector eo. The ordering of the edges and of the
vertices is the same
    as Sage's vertices and edges methods.

    INPUT:
        Gamma - graph
        eo - a vector of 1's and -1's whose length is the number of
edges in Gamma
             (ie, the size of Gamma, M)

    EXAMPLES:
        sage: Gamma = graphs.PaleyGraph(9)
        sage: E = Gamma.edges()
        sage: V = Gamma.vertices()
        sage: eo = [1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1,
1, 1, -1, -1]
        sage: B = incidence_matrix(Gamma, eo); B
        [ 1 -1  1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
        [-1  0  0  0 -1 -1  1  0  0  0  0  0  0  0  0  0  0  0]
        [ 0  1  0  0  1  0  0 -1  1  0  0  0  0  0  0  0  0  0]
        [ 0  0  0  0  0  0  0  1  0  1 -1 -1  0  0  0  0  0  0]
        [ 0  0 -1  0  0  0  0  0  0 -1  0  0  1 -1  0  0  0  0]
        [ 0  0  0  0  0  1  0  0  0  0  1  0 -1  0  1  0  0  0]
        [ 0  0  0  0  0  0 -1  0  0  0  0  0  0  0 -1  1 -1  0]
        [ 0  0  0  0  0  0  0  0 -1  0  0  1  0  0  0 -1  0 -1]
        [ 0  0  0 -1  0  0  0  0  0  0  0  0  0  1  0  0  1  1]
        sage: B.transpose()*B == Gamma.laplacian_matrix()
        True

    """
    E = Gamma.edges()
    V = Gamma.vertices()
    IG = [[incidence_value(Gamma, v, e, eo) for v in V] for e in E]
    return matrix(QQ, IG).transpose()



> Vincent
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to