Skip to content

Custom Edge/Node Formatters for Dot Output? #194

@bnbowman

Description

@bnbowman

I'm writing a Partial-Order Aligner for DNA sequence, using petgraph as my underlying graph implementation. Currently I'm using chars as my node-weight type so that when I debug things by in Dot format i see the underlying sequence, however the rest of the code uses the underlying weights as u8's for ease of comparison with text slices necessitating a bunch of conversions.

What I'd like to do ideally is use u8's all around and then simply customize the formatter to convert my node weights from u8 to char when being output to file. It looks like the underlying code already supports node and edge-specific formatters:

    fn graph_fmt<NF, EF, NW, EW>(&self, g: G, f: &mut fmt::Formatter,
                    mut node_fmt: NF, mut edge_fmt: EF) -> fmt::Result
        where G: NodeIndexable + IntoNodeReferences + IntoEdgeReferences,
              G: GraphProp,
              G: Data<NodeWeight=NW, EdgeWeight=EW>,
              NF: FnMut(&NW, &mut FnMut(&Display) -> fmt::Result) -> fmt::Result,
              EF: FnMut(&EW, &mut FnMut(&Display) -> fmt::Result) -> fmt::Result,
    { ... }

But it's not clear to me how this code is being called and how it could be modified by a user. Suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-questionCategory: User questions that are neither featureP-help-wantedCall for participation: Help is requested to fix this issueS-nominated-to-closeStatus: A contributor thinks this PR or issue should be closed out

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions