Skip to content

Commit

Permalink
Add support for xml serialization of undirected graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonTC committed Jul 14, 2020
1 parent 9c5c8bc commit f397d9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/QuikGraph.Serialization/SerializationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public static void SerializeToXml<TVertex, TEdge, TGraph>(
[NotNull] string vertexElementName,
[NotNull] string edgeElementName,
[NotNull] string namespaceUri)
where TGraph : IVertexAndEdgeListGraph<TVertex, TEdge>
where TGraph : IEdgeListGraph<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
SerializeToXml(
Expand Down Expand Up @@ -371,7 +371,7 @@ public static void SerializeToXml<TVertex, TEdge, TGraph>(
[CanBeNull, InstantHandle] Action<XmlWriter, TGraph> writeGraphAttributes,
[CanBeNull, InstantHandle] Action<XmlWriter, TVertex> writeVertexAttributes,
[CanBeNull, InstantHandle] Action<XmlWriter, TEdge> writeEdgeAttributes)
where TGraph : IVertexAndEdgeListGraph<TVertex, TEdge>
where TGraph : IEdgeListGraph<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
if (graph == null)
Expand Down
5 changes: 2 additions & 3 deletions tests/QuikGraph.Serialization.Tests/XmlSerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ private static IEnumerable<TestCaseData> XmlSerializationGraphTestCases
{
yield return new TestCaseData(new AdjacencyGraph<Person, TaggedEdge<Person, string>>());
yield return new TestCaseData(new BidirectionalGraph<Person, TaggedEdge<Person, string>>());
yield return new TestCaseData(new UndirectedGraph<Person, TaggedEdge<Person, string>>());
}
}

[TestCaseSource(nameof(XmlSerializationGraphTestCases))]
public void SerializeToXml<TGraph>([NotNull] TGraph graph)
where TGraph
: IVertexAndEdgeListGraph<Person, TaggedEdge<Person, string>>
, IMutableVertexAndEdgeSet<Person, TaggedEdge<Person, string>>
where TGraph: IMutableVertexAndEdgeSet<Person, TaggedEdge<Person, string>>
{
var persons = new List<Person>();
var jacob = new Person("Jacob", "Hochstetler")
Expand Down

0 comments on commit f397d9b

Please sign in to comment.