"@ Werner: "->" is not the same as \DirectedEdge, otherwise I would have no reason to changed it. Did you run the code with my corrections in it (as posted above)?"
Oh, what a shame! I missed that point indeed and defined the graphData with rules instead of (Un)DirectedEdge. I am embarrassed.
Strange enough, Graph accepts this wrong definition (See case 1.1. in my original code). I am somewhat confused.
Anyway, I fixed my code now by changing rules to DirectedEdge as data for Graph (Case 1, see below). For TreePlot and FindPath graphData still has to use rules instead of DirectedEdge (Case 2). I added a new case 3 as well which uses labeled vertices and labeled edges in a form suitable for Graph.
All in all this doesn't change very much. The basic problem that TreePlot does not accept a general Graph-object still holds true. Whereas FindPath does.
I come back to Sam Carretties hint to use TreeGraph, which should be the solution (See case 4 below). TreeGraph accepts the same defining data as Graph, i.e based on (Un)DirectedEdge, possibly with an explicit list of vertices. Edges and vertices can both be labeled (or - as I assume - wrapped with any other properties). Hence:
Define graphData in a form suitable for Graph and TreeGraph, i.e. (Un)DirectedEdge, possibly explicit vertices, possibly wrapped for labels or other properties.
use TreePlot[TreeGraph[graphData],...]
use FindPath[Graph[graphData],...]
But this does not work either. Maybe because of TreeGraph not accepting my not-so-nice-Tree (Common endnode c. Although it is connected and cycle-free). Hence I changed my graphData to a proper tree, adding another leave c2 and edge b2->c2 (See case 5 below). But this doesn't work either.
Before you read my following code just read my next message, which should be easier to understand.
If[True, (* Test Graph (from Graph-Data) & TreePlot & FindPath *)
Block[{a, b1, b2, c, graphData, graph, treeGraph},
(* Define graphData as a labeled list of edges in a form suitable \
for Graph (using DirectedEdge) *)
Print[];
Print[Style[
"1 Defining a graph with edge labels by graphData suitable for \
Graph", Red, Bold, Larger]];
graphData = {Labeled[a \[DirectedEdge] b1, "a,b1"],
Labeled[a \[DirectedEdge] b2, "a,b2"], b1 \[DirectedEdge] c,
b2 \[DirectedEdge] c};
Echo[graphData, "1 graphData: "];
(* Make a Graph-object from graphData *)
graph = Graph[graphData];
Echo[Row[{Head[graph], " ", graph}],
"1 make graph from graphData: "];
(* TreePlot and FindPath from graphData *)
Print[Style["\n1.1 TreePlot from graphData", Blue, Bold]];
Print[TreePlot[graphData, Left, a,
PlotLabel -> Style["1.1 TreePlot from graphData", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"1.1 FindPath from graphData: All paths from a to c: ",
FindPath[graphData, a, c, Infinity, All]}], Blue, Bold]];
(* TreePlot and FindPath from graph *)
Print[Style["\n1.2 TreePlot from graph", Blue, Bold]];
Print[TreePlot[graph, Left, a,
PlotLabel -> Style["1.2 TreePlot from graph", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"1.2 FindPath from graph: All paths from a to c: ",
FindPath[graph, a, c, Infinity, All]}], Blue, Bold]];
(* Define graphData as a labeled list of edges in a Form suitable \
for TreePlot (using rules) *)
Print[];
Print[Style[
"2 Defining a graph with edge labels by graphData suitable for \
TreePlot", Red, Bold, Larger]];
graphData = {{a -> b1, "a,b1"}, {a -> b2, "a,b2"}, b1 -> c, b2 -> c};
Echo[graphData, "2 graphData: "];
(* Make a Graph-object from graphData *)
graph = Graph[graphData];
Echo[Row[{Head[graph], " ", graph}],
"2 make graph from graphData: "];
(* TreePlot and FindPath from graphData *)
Print[Style["\n2.1 TreePlot from graphData", Blue, Bold]];
Print[TreePlot[graphData, Left, a,
PlotLabel -> Style["2.1 TreePlot from graphData", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"\n2.1 FindPath from graphData: All paths from a to c: ",
FindPath[graphData, a, c, Infinity, All]}], Blue, Bold]];
(* TreePlot and FindPath from graph *)
Print[Style["\n2.2 TreePlot from graph", Blue, Bold]];
Print[TreePlot[graph, Left, a,
PlotLabel -> Style["2.2 TreePlot from graph", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"2.2 FindPath from graph: All paths from a to c: ",
FindPath[graph, a, c, Infinity, All]}], Blue, Bold]];
(* Define graphData as a labeled list of vertices and edges in a \
form suitable for Graph (using DirectedEdge) *)
Print[];
Print[Style[
"3 Defining a graph with vertex- and edge-labels by graphData \
suitable for Graph", Red, Bold, Larger]];
graphData = {
{Labeled[a, "S=a"], b1, b2, Labeled[c, "E=c"]},
{Labeled[a \[DirectedEdge] b1, "a,b1"],
Labeled[a \[DirectedEdge] b2, "a,b2"], b1 \[DirectedEdge] c,
b2 \[DirectedEdge] c}
};
Echo[graphData, "3 graphData: "];
(* Make a Graph-object from graphData *)
graph = Graph[graphData[[1]], graphData[[2]]];
Echo[Row[{Head[graph], " ", graph}],
"3 make graph from graphData: "];
(* TreePlot and FindPath from graphData *)
Print[Style["\n3.1 TreePlot from graphData", Blue, Bold]];
Print[TreePlot[graphData[[2]], Left, a,
PlotLabel -> Style["3.1 TreePlot from graphData", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"3.1 FindPath from graphData: All paths from a to c: ",
FindPath[graphData[[2]], a, c, Infinity, All]}], Blue, Bold]];
(* TreePlot and FindPath from graph *)
Print[Style["\n3.2 TreePlot from graph", Blue, Bold]];
Print[TreePlot[graph, Left, a,
PlotLabel -> Style["3.2 TreePlot from graph", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"3.2 FindPath from graph: All paths from a to c: ",
FindPath[graph, a, c, Infinity, All]}], Blue, Bold]];
(* Define graphData as a labeled list of vertices and edges in a \
form suitable for Graph (using DirectedEdge).
Use Graph and TreeGraph for creation of suitable Graph-objects. *)
Print[];
Print[Style[
"4 Defining a graph with vertex- and edge-labels by graphData \
suitable for Graph and TreeGraph", Red, Bold, Larger]];
graphData = {
{Labeled[a, "S=a"], b1, b2, Labeled[c, "E=c"]},
{Labeled[a \[DirectedEdge] b1, "a,b1"],
Labeled[a \[DirectedEdge] b2, "a,b2"], b1 \[DirectedEdge] c,
b2 \[DirectedEdge] c}
};
Echo[graphData, "4 graphData: "];
(* Make a Graph-object by Graph from graphData *)
graph = Graph[graphData[[1]], graphData[[2]]];
Echo[Row[{Head[graph], " ", graph}],
"4a make graph by Graph from graphData: "];
(* Make a Graph-object by TreeGraph from graphData *)
treeGraph = TreeGraph[graphData[[1]], graphData[[2]]];
Echo[Row[{Head[treeGraph], " ", treeGraph, " is a tree: ",
TreeGraphQ[treeGraph]}],
"4b make treeGraph by TreeGraph from graphData: "];
(* TreePlot and FindPath from Graph-objects *)
Print[Style["\n4.2 TreePlot from treeGraph", Blue, Bold]];
Print[TreePlot[treeGraph, Left, a,
PlotLabel -> Style["4.2 TreePlot from treeGraph", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"4.2 FindPath from graph: All paths from a to c: ",
FindPath[graph, a, c, Infinity, All]}], Blue, Bold]];
(* Same as case 4, but with a true tree.
Define graphData as a labeled list of vertices and edges in a form \
suitable for Graph (using DirectedEdge).
Use Graph and TreeGraph for creation of suitable Graph-objects. *)
Print[];
Print[Style[
"5 Defining a true tree graph with vertex- and edge-labels by \
graphData suitable for Graph and TreeGraph", Red, Bold, Larger]];
graphData = {
{Labeled[a, "S=a"], b1, b2, Labeled[c, "E=c"],
Labeled[c2, "E=c2"]},
{Labeled[a \[DirectedEdge] b1, "a,b1"],
Labeled[a \[DirectedEdge] b2, "a,b2"], b1 \[DirectedEdge] c,
b2 \[DirectedEdge] c2}
};
Echo[graphData, "5 graphData: "];
(* Make a Graph-object by Graph from graphData *)
graph = Graph[graphData[[1]], graphData[[2]]];
Echo[Row[{Head[graph], " ", graph}],
"5a make graph by Graph from graphData: "];
(* Make a Graph-object by TreeGraph from graphData *)
treeGraph = TreeGraph[graphData[[1]], graphData[[2]]];
Echo[Row[{Head[treeGraph], " ", treeGraph, " is a tree: ",
TreeGraphQ[treeGraph]}],
"5b make treeGraph by TreeGraph from graphData: "];
(* TreePlot and FindPath from Graph-objects *)
Print[Style["\n5.2 TreePlot from treeGraph", Blue, Bold]];
Print[TreePlot[treeGraph, Left, a,
PlotLabel -> Style["5.2 TreePlot from treeGraph", Blue, Bold],
DirectedEdges -> True, VertexLabeling -> True,
EdgeLabeling -> True]];
Print[Style[
Row[{"5.2.1 FindPath from graph: All paths from a to c: ",
FindPath[graph, a, c, Infinity, All]}