├── .gitignore ├── .hgignore ├── Releases ├── README.txt ├── nuget_pack.cmd └── releaser.bat ├── Source ├── Graph#.Controls │ ├── Behaviors │ │ └── DragBehavior.cs │ ├── Controls │ │ ├── AlgorithmConstraints.cs │ │ ├── AnimationContext.cs │ │ ├── Animations │ │ │ └── SimpleMoveAnimation.cs │ │ ├── CompoundVertexControl.cs │ │ ├── ContextualGraphLayout.cs │ │ ├── EdgeControl.cs │ │ ├── GraphCanvas.cs │ │ ├── GraphElementControl.cs │ │ ├── GraphLayout.DependencyProperties.cs │ │ ├── GraphLayout.GraphElements.cs │ │ ├── GraphLayout.HighlightController.cs │ │ ├── GraphLayout.cs │ │ ├── IAnimation.cs │ │ ├── IAnimationContext.cs │ │ ├── ICompoundVertexControl.cs │ │ ├── ITransition.cs │ │ ├── LayoutMode.cs │ │ ├── PositionChangedEventArgs.cs │ │ ├── PositionChangedEventHandler.cs │ │ ├── Transitions │ │ │ ├── FadeInTransition.cs │ │ │ ├── FadeOutTransition.cs │ │ │ ├── FadeTransition.cs │ │ │ └── TransitionBase.cs │ │ └── VertexControl.cs │ ├── Converters │ │ ├── CoordinatesToPointConverter.cs │ │ ├── EdgeRouteToPathConverter.cs │ │ └── PointArrayToString.cs │ ├── GraphSharp.Controls.csproj │ ├── GraphSharp.Controls.csproj.vspscc │ ├── GraphSharp.Controls.nuspec │ ├── GraphSharp.snk │ ├── Helpers │ │ └── ObjectPool.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Themes │ │ └── Generic.xaml │ └── packages.config ├── Graph#.Sample │ ├── App.xaml │ ├── App.xaml.cs │ ├── Converters │ │ ├── BoolToVisibilityConverter.cs │ │ └── DoubleToIntegerConverter.cs │ ├── GraphSharp.Sample.csproj │ ├── GraphSharp.Sample.csproj.vspscc │ ├── LayoutManager.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Model │ │ └── GraphModel.cs │ ├── PlainCompoundLayoutTest.xaml │ ├── PlainCompoundLayoutTest.xaml.cs │ ├── PocEdge.cs │ ├── PocGraph.cs │ ├── PocSerializeHelper.cs │ ├── PocVertex.cs │ ├── PocVertexToLayoutModeConverter.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Resources │ │ ├── GraphicResources.xaml │ │ ├── LayoutParameterTemplates.xaml │ │ └── PocGraphDataTemplates.xaml │ ├── RibbonCommands.xaml │ ├── TestCompoundLayout.xaml │ ├── TestCompoundLayout.xaml.cs │ ├── TestContextualLayout.xaml │ ├── TestContextualLayout.xaml.cs │ ├── TestWindow.xaml │ ├── TestWindow.xaml.cs │ ├── ViewModel │ │ ├── GraphLayoutViewModel.cs │ │ ├── LayoutAnalyzerViewModel.SampleGraphs.cs │ │ └── LayoutAnalyzerViewModel.cs │ ├── app.config │ ├── icons │ │ ├── Add.xaml │ │ ├── Back.xaml │ │ ├── Block.xaml │ │ ├── Check.xaml │ │ ├── Configurator.xaml │ │ ├── Delete.xaml │ │ ├── Down.xaml │ │ ├── Down1.xaml │ │ ├── Edit.xaml │ │ ├── Error.xaml │ │ ├── Exit.xaml │ │ ├── File.xaml │ │ ├── Find.xaml │ │ ├── Find_Next.xaml │ │ ├── Forward.xaml │ │ ├── GraphSharp.png │ │ ├── Help.xaml │ │ ├── Left.xaml │ │ ├── Left1.xaml │ │ ├── Lock.xaml │ │ ├── Open.xaml │ │ ├── Padlock.xaml │ │ ├── Printer.xaml │ │ ├── Redo.xaml │ │ ├── Refresh.xaml │ │ ├── Right.xaml │ │ ├── Right1.xaml │ │ ├── Save.xaml │ │ ├── Save_As.xaml │ │ ├── Search.xaml │ │ ├── Undo.xaml │ │ ├── Up.xaml │ │ ├── Up1.xaml │ │ ├── Warning.xaml │ │ ├── Zoom_in.xaml │ │ └── Zoom_out.xaml │ └── packages.config ├── Graph#.Test │ ├── Algorithms │ │ └── CompoundFDPForceTest.cs │ ├── Generators │ │ └── GraphGenerator.cs │ ├── GraphHelperTest.cs │ ├── GraphSharp.Test.csproj │ ├── GraphSharp.Test.csproj.vspscc │ ├── LayeredTopologicalSortAlgorithmTest.cs │ ├── LayoutHelperTest.cs │ ├── MetricTests │ │ └── LayoutAlgorithmTest.cs │ ├── Metrics │ │ ├── EdgeMetricCalculator.cs │ │ ├── IMetricCalculator.cs │ │ ├── LayoutAreaMetricCalculator.cs │ │ ├── MetricCalculatorBase.cs │ │ └── OverlapMetricCalculator.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── Graph# │ ├── Algorithms │ │ ├── AlgorithmBase.cs │ │ ├── EdgeRouting │ │ │ ├── BundleEdgeRoutingAlgorithm.cs │ │ │ ├── BundleEdgeRoutingParameters.cs │ │ │ ├── EdgeRoutingAlgorithmBase.cs │ │ │ ├── EdgeRoutingParameters.cs │ │ │ ├── IEdgeRoutingAlgorithm.cs │ │ │ ├── IEdgeRoutingAlgorithmFactory.cs │ │ │ ├── IEdgeRoutingParameters.cs │ │ │ ├── Obstacle.cs │ │ │ ├── ObstacleSegment.cs │ │ │ ├── PointVertex.cs │ │ │ ├── RotationTreeNode.cs │ │ │ ├── StandardEdgeRoutingAlgorithmFactory.cs │ │ │ └── VisibilityGraph.cs │ │ ├── FactoryHelper.cs │ │ ├── Highlight │ │ │ ├── HierarchicalHighlightAlgorithm.cs │ │ │ ├── HighlightAlgorithmBase.cs │ │ │ ├── HighlightContext.cs │ │ │ ├── HighlightParameterBase.cs │ │ │ ├── IHighlightAlgorithm.cs │ │ │ ├── IHighlightAlgorithmFactory.cs │ │ │ ├── IHighlightContext.cs │ │ │ ├── IHighlightController.cs │ │ │ ├── IHighlightParameters.cs │ │ │ ├── SimpleHighlightAlgorithm.cs │ │ │ ├── StandardHighlightAlgorithmFactory.cs │ │ │ ├── UndirectedHighlightAlgorithm.cs │ │ │ └── UndirectedHighlightParameters.cs │ │ ├── IAlgorithm.cs │ │ ├── IAlgorithmParameters.cs │ │ ├── LayeredTopologicalSortAlgorithm.cs │ │ ├── Layout │ │ │ ├── Compound │ │ │ │ ├── CompoundLayoutContext.cs │ │ │ │ ├── CompoundLayoutIterationEventArgs.cs │ │ │ │ ├── CompoundVertexInnerLayoutType.cs │ │ │ │ ├── FDP │ │ │ │ │ ├── CompoundFDPLayoutAlgorithm.Data.cs │ │ │ │ │ ├── CompoundFDPLayoutAlgorithm.Init.cs │ │ │ │ │ ├── CompoundFDPLayoutAlgorithm.cs │ │ │ │ │ └── CompoundFDPLayoutParameters.cs │ │ │ │ ├── ICompoundLayoutAlgorithm.cs │ │ │ │ ├── ICompoundLayoutContext.cs │ │ │ │ ├── ICompoundLayoutIterationEventArgs.cs │ │ │ │ ├── TestingCompoundLayoutIterationEventArgs.cs │ │ │ │ └── TestingCompoundVertexInfo.cs │ │ │ ├── Contextual │ │ │ │ ├── ContextualLayoutAlgorithmFactory.cs │ │ │ │ ├── ContextualLayoutContext.cs │ │ │ │ ├── DoubleTreeLayoutAlgorithm.cs │ │ │ │ ├── DoubleTreeLayoutParameters.cs │ │ │ │ ├── IContextualLayoutAlgorithmFactory.cs │ │ │ │ ├── RadialTreeLayoutAlgorithm.cs │ │ │ │ └── RadialTreeLayoutParameters.cs │ │ │ ├── ILayoutAlgorithm.cs │ │ │ ├── ILayoutAlgorithmFactory.cs │ │ │ ├── ILayoutContext.cs │ │ │ ├── ILayoutInfoIterationEventArgs.cs │ │ │ ├── ILayoutIterationEventArgs.cs │ │ │ ├── ILayoutParameters.cs │ │ │ ├── IParameterizedLayoutAlgorithm.cs │ │ │ ├── LayoutAlgorithmBase.cs │ │ │ ├── LayoutContext.cs │ │ │ ├── LayoutDirection.cs │ │ │ ├── LayoutIterationEventArgs.cs │ │ │ ├── LayoutMode.cs │ │ │ ├── LayoutParametersBase.cs │ │ │ ├── LayoutState.cs │ │ │ ├── LayoutUtil.cs │ │ │ ├── ParameterizedLayoutAlgorithmBase.cs │ │ │ ├── Simple │ │ │ │ ├── Circular │ │ │ │ │ ├── CircularLayoutAlgorithm.cs │ │ │ │ │ └── CircularLayoutParameters.cs │ │ │ │ ├── FDP │ │ │ │ │ ├── BoundedFRLayoutParameters.cs │ │ │ │ │ ├── FRCoolingFunction.cs │ │ │ │ │ ├── FRLayoutAlgorithm.cs │ │ │ │ │ ├── FRLayoutParametersBase.cs │ │ │ │ │ ├── FreeFRLayoutParameters.cs │ │ │ │ │ ├── ISOMLayoutAlgorithm.cs │ │ │ │ │ ├── ISOMLayoutParameters.cs │ │ │ │ │ ├── KKLayoutAlgorithm.cs │ │ │ │ │ ├── KKLayoutParameters.cs │ │ │ │ │ ├── LinLogLayoutAlgorithm.QuadTree.cs │ │ │ │ │ ├── LinLogLayoutAlgorithm.cs │ │ │ │ │ ├── LinLogLayoutParameters.cs │ │ │ │ │ ├── StressMajorizationLayoutAlgorithm.cs │ │ │ │ │ └── StressMajorizationLayoutParameters.cs │ │ │ │ ├── Grid │ │ │ │ │ ├── GridLayoutAlgorithm.cs │ │ │ │ │ └── GridLayoutParameters.cs │ │ │ │ ├── Hierarchical │ │ │ │ │ ├── EfficientSugiyamaAlgorithm.BuildSparseNormalizedGraph.cs │ │ │ │ │ ├── EfficientSugiyamaAlgorithm.DoCrossingMinimizations.cs │ │ │ │ │ ├── EfficientSugiyamaAlgorithm.DoPreparing.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutAlgorithm.AlternatingLayer.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutAlgorithm.Data.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutAlgorithm.HorizontalAssignment.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutAlgorithm.SegmentContainer.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutAlgorithm.cs │ │ │ │ │ ├── EfficientSugiyamaLayoutParameters.cs │ │ │ │ │ ├── SugiyamaEdgeRoutings.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.Enums.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.SugiEdge.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.SugiVertex.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.VertexLayer.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.VertexLayerCollection.cs │ │ │ │ │ ├── SugiyamaLayoutAlgorithm.cs │ │ │ │ │ └── SugiyamaLayoutParameters.cs │ │ │ │ └── Tree │ │ │ │ │ ├── BalloonTreeLayoutAlgorithm.cs │ │ │ │ │ ├── BalloonTreeLayoutParameters.cs │ │ │ │ │ ├── SimpleTreeLayoutAlgorithm.Data.cs │ │ │ │ │ ├── SimpleTreeLayoutAlgorithm.WidthAndHeightOpt.cs │ │ │ │ │ ├── SimpleTreeLayoutAlgorithm.cs │ │ │ │ │ ├── SimpleTreeLayoutParameters.cs │ │ │ │ │ └── SpanningTreeGeneration.cs │ │ │ └── StandardLayoutAlgorithmFactory.cs │ │ └── OverlapRemoval │ │ │ ├── FSAAlgorithm.cs │ │ │ ├── IOverlapRemovalAlgorithm.cs │ │ │ ├── IOverlapRemovalAlgorithmFactory.cs │ │ │ ├── IOverlapRemovalContext.cs │ │ │ ├── IOverlapRemovalParameters.cs │ │ │ ├── OneWayFSAAlgorithm.cs │ │ │ ├── OneWayFSAParameters.cs │ │ │ ├── OverlapRemovalAlgorithmBase.cs │ │ │ ├── OverlapRemovalContext.cs │ │ │ ├── OverlapRemovalHelper.cs │ │ │ ├── OverlapRemovalParameters.cs │ │ │ ├── RectangleWrapper.cs │ │ │ └── StandardOverlapRemovalAlgorithmFactory.cs │ ├── ClassDiagrams │ │ ├── Algorithm Interfaces.cd │ │ └── Implemented Algorithms.cd │ ├── CompoundGraph.cs │ ├── Contracts │ │ ├── ICompoundGraphContract.cs │ │ ├── IContextualLayoutAlgorithmFactoryContract.cs │ │ ├── ILayoutAlgorithmFactoryContract.cs │ │ └── ILayoutContextContract.cs │ ├── GraphHelper.cs │ ├── GraphHideHelper.cs │ ├── GraphSharp.csproj │ ├── GraphSharp.csproj.vspscc │ ├── GraphSharp.snk │ ├── HierarchicalGraph.cs │ ├── ICompoundGraph.cs │ ├── IHierarchicalBidirectionalGraph.cs │ ├── ILengthEdge.cs │ ├── IMutableCompoundGraph.cs │ ├── ISoftMutableGraph.cs │ ├── ITypedEdge.cs │ ├── IWeightedEdge.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SoftMutableBidirectionalGraph.cs │ ├── SoftMutableHierarchicalGraph.cs │ ├── WrappedVertex.cs │ └── packages.config ├── GraphSharp.Optimization │ ├── Algorithms │ │ └── Layout │ │ │ └── CompoundFDP │ │ │ └── GeneticCompoundFDPOptimizer.cs │ ├── App.xaml │ ├── App.xaml.cs │ ├── GeneticAlgorithm │ │ ├── GeneticAlgorithmBase.cs │ │ ├── GeneticAlgorithmParameters.cs │ │ └── IMutation.cs │ ├── GraphSharp.Optimization.csproj │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Window1.xaml │ └── Window1.xaml.cs ├── GraphSharp.sln ├── Libraries │ └── RibbonControlsLibrary.dll └── TestGraphs │ ├── Sugiyama │ ├── BigSugiyama.gml │ ├── BigSugiyama2.gml │ ├── SugiyamaTester1.gml │ ├── SugiyamaTester10.gml │ ├── SugiyamaTester11.gml │ ├── SugiyamaTester12.gml │ ├── SugiyamaTester12_dummy.gml │ ├── SugiyamaTester12_sparse.gml │ ├── SugiyamaTester13.gml │ ├── SugiyamaTester14.gml │ ├── SugiyamaTester15.gml │ ├── SugiyamaTester16.gml │ ├── SugiyamaTester2.gml │ ├── SugiyamaTester3.gml │ ├── SugiyamaTester4.gml │ ├── SugiyamaTester5.gml │ ├── SugiyamaTester6.gml │ ├── SugiyamaTester7.gml │ ├── SugiyamaTester8.gml │ └── SugiyamaTester9.gml │ ├── Symmetry.gml │ └── WidthAndHeightOpt │ ├── WHO1.gml │ └── WHO2.gml └── Tutorials ├── GraphSharpTutorial01 ├── GraphSharpTutorial01.sln ├── GraphSharpTutorial01.suo └── GraphSharpTutorial01 │ ├── App.xaml │ ├── App.xaml.cs │ ├── GraphSharpTutorial01.csproj │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Window1.xaml │ ├── Window1.xaml.cs │ ├── bin │ └── Debug │ │ ├── GraphSharp.Controls.dll │ │ ├── GraphSharp.dll │ │ ├── GraphSharp.pdb │ │ ├── GraphSharpTutorial01.exe │ │ ├── GraphSharpTutorial01.pdb │ │ ├── GraphSharpTutorial01.vshost.exe │ │ ├── GraphSharpTutorial01.vshost.exe.manifest │ │ ├── QuickGraph.dll │ │ └── WPFExtensions.dll │ └── obj │ └── Debug │ ├── App.g.cs │ ├── GraphSharpTutorial01.Properties.Resources.resources │ ├── GraphSharpTutorial01.csproj.FileListAbsolute.txt │ ├── GraphSharpTutorial01.csproj.GenerateResource.Cache │ ├── GraphSharpTutorial01.exe │ ├── GraphSharpTutorial01.g.resources │ ├── GraphSharpTutorial01.pdb │ ├── GraphSharpTutorial01_MarkupCompile.cache │ ├── ResolveAssemblyReference.cache │ ├── Window1.baml │ └── Window1.g.cs └── MyTestApp ├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── App.xaml ├── App.xaml.cs ├── Converter ├── EdgeRouteToLabelConverter.cs ├── EdgeRouteToPathConverter.cs └── GraphConverterHelper.cs ├── GraphTemplates.xaml ├── MyTestApp.csproj ├── MyTestApp.sln ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── UMLGraph.cs ├── UpgradeLog.XML ├── ViewModels └── ClassViewModel.cs ├── Window1.xaml ├── Window1.xaml.cs ├── app.config └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | *.nupkg 4 | *.suo 5 | *.csproj.user 6 | .vs/ 7 | 8 | # Only commit repositories.config. The rest of /packages is only a local cache 9 | !/Source/packages/repositories.config 10 | /Source/packages/* 11 | 12 | !/Tutorials/MyTestApp/packages/repositories.config 13 | /Tutorials/MyTestApp/packages/* 14 | *.user 15 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | */bin/* 3 | */obj/* 4 | bin/* 5 | -------------------------------------------------------------------------------- /Releases/README.txt: -------------------------------------------------------------------------------- 1 | To make a release, just call the releaser.bat with the version number. It will create the bin, source and example zip files. 2 | 3 | Example: 4 | 5 | > releaser.bat 1.0 6 | 7 | 8 | Important: 9 | ---------- 10 | 11 | You should have an svn client installed to your computer and it's bin directory should be added to your PATH environment 12 | variable. 13 | You must have install 7-zip (www.7-zip.org) to your C:\Program Files\7-zip directory. -------------------------------------------------------------------------------- /Releases/nuget_pack.cmd: -------------------------------------------------------------------------------- 1 | @..\Source\.nuget\NuGet.exe pack "..\Source\Graph#.Controls\GraphSharp.Controls.csproj" -Prop Configuration=Release -------------------------------------------------------------------------------- /Releases/releaser.bat: -------------------------------------------------------------------------------- 1 | set PATH=%PATH%;c:\Windows\Microsoft.NET\Framework\v3.5\; 2 | set PATH=%PATH%;"c:\Program Files\7-Zip\"; 3 | 4 | set Solution=GraphSharp 5 | set RFolder=..\Releases 6 | set RelativeFolder=..\%RFolder% 7 | 8 | set ReleaseRootFolder=%date:~0,4%-%date:~5,2%-%date:~8,2%-v%1 9 | set ReleaseFolder=%ReleaseRootFolder%\Release 10 | set SampleFolder=%ReleaseRootFolder%\Sample 11 | set SourceFolder=%ReleaseRootFolder%\Source 12 | 13 | mkdir %ReleaseFolder% 14 | mkdir %SampleFolder% 15 | mkdir %SourceFolder% 16 | 17 | cd ..\Source 18 | 19 | rem Create The Release 20 | 21 | rem --- Algorithms --- 22 | MSBuild.exe .\Graph#\GraphSharp.csproj /p:Configuration=Release;TargetFrameworkVersion=v3.5;OutDir=%RelativeFolder%\%ReleaseFolder%\ 23 | 24 | rem --- Controls --- 25 | MSBuild.exe .\Graph#.Controls\GraphSharp.Controls.csproj /p:Configuration=Release;TargetFrameworkVersion=3.5;OutDir=%RelativeFolder%\%ReleaseFolder%\ 26 | 27 | 28 | rem Create The Sample 29 | 30 | MSBuild.exe .\Graph#.Sample\GraphSharp.Sample.csproj /t:Rebuild /p:Configuration=Release;TargetFrameworkVersion=v3.5;OutDir=%RelativeFolder%\%SampleFolder%\ 31 | 32 | 33 | rem Copy The Source 34 | cd %RFolder%\%SourceFolder% 35 | "%CPCFOLDER%"\cpc.exe checkout %Solution% 36 | 37 | 38 | cd ..\ 39 | 7z a -r0 %Solution%-v%1-release.zip Release\*.* 40 | 7z a -r0 %Solution%-v%1-sample.zip Sample\*.* 41 | 7z a -r0 %Solution%-v%1-source.zip Source\*.* 42 | 43 | rmdir /S /Q Release 44 | rmdir /S /Q Sample 45 | rmdir /S /Q Source 46 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/AlgorithmConstraints.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Controls 7 | { 8 | public enum AlgorithmConstraints 9 | { 10 | Must, 11 | Automatic, 12 | Skip 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/AnimationContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Contracts; 3 | 4 | namespace GraphSharp.Controls 5 | { 6 | public class AnimationContext : IAnimationContext 7 | { 8 | public GraphCanvas GraphCanvas { get; private set; } 9 | 10 | public AnimationContext( GraphCanvas canvas ) 11 | { 12 | GraphCanvas = canvas; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/Animations/SimpleMoveAnimation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Media.Animation; 7 | 8 | namespace GraphSharp.Controls.Animations 9 | { 10 | public class SimpleMoveAnimation : IAnimation 11 | { 12 | #region IAnimation Members 13 | 14 | public void Animate( IAnimationContext context, System.Windows.Controls.Control control, double x, double y, TimeSpan duration ) 15 | { 16 | if ( !double.IsNaN( x ) ) 17 | { 18 | double from = GraphCanvas.GetX( control ); 19 | from = double.IsNaN( from ) ? 0.0 : from; 20 | 21 | //create the animation for the horizontal position 22 | var animationX = new DoubleAnimation( 23 | from, 24 | x, 25 | duration, 26 | FillBehavior.HoldEnd ); 27 | animationX.Completed += ( s, e ) => 28 | { 29 | control.BeginAnimation( GraphCanvas.XProperty, null ); 30 | control.SetValue( GraphCanvas.XProperty, x ); 31 | }; 32 | control.BeginAnimation( GraphCanvas.XProperty, animationX, HandoffBehavior.Compose ); 33 | } 34 | if ( !double.IsNaN( y ) ) 35 | { 36 | double from = GraphCanvas.GetY( control ); 37 | from = ( double.IsNaN( from ) ? 0.0 : from ); 38 | 39 | //create an animation for the vertical position 40 | var animationY = new DoubleAnimation( 41 | from, y, 42 | duration, 43 | FillBehavior.HoldEnd ); 44 | animationY.Completed += ( s, e ) => 45 | { 46 | control.BeginAnimation( GraphCanvas.YProperty, null ); 47 | control.SetValue( GraphCanvas.YProperty, y ); 48 | }; 49 | control.BeginAnimation( GraphCanvas.YProperty, animationY, HandoffBehavior.Compose ); 50 | } 51 | } 52 | 53 | #endregion 54 | } 55 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/ContextualGraphLayout.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using GraphSharp.Algorithms.Layout; 3 | using QuickGraph; 4 | using System.Windows; 5 | using GraphSharp.Algorithms.Layout.Contextual; 6 | 7 | namespace GraphSharp.Controls 8 | { 9 | public class ContextualGraphLayout : GraphLayout 10 | where TVertex : class 11 | where TEdge : IEdge 12 | where TGraph : class, IBidirectionalGraph 13 | { 14 | #region Dependency Properties 15 | /// 16 | /// Gets or sets the SelectedVertex which influences the Context. 17 | /// 18 | public TVertex SelectedVertex 19 | { 20 | get { return (TVertex)GetValue( SelectedVertexProperty ); } 21 | set { SetValue( SelectedVertexProperty, value ); } 22 | } 23 | 24 | public static readonly DependencyProperty SelectedVertexProperty = DependencyProperty.Register( "SelectedVertex", typeof( TVertex ), typeof( ContextualGraphLayout ), new UIPropertyMetadata( default( TVertex ), SelectedVertex_PropertyChanged ) ); 25 | 26 | private static void SelectedVertex_PropertyChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args ) 27 | { 28 | var gl = obj as ContextualGraphLayout; 29 | if ( gl == null ) 30 | return; 31 | 32 | //refresh the layout on context change 33 | gl.Relayout(); 34 | } 35 | #endregion 36 | 37 | static ContextualGraphLayout() 38 | { 39 | LayoutAlgorithmFactoryProperty.OverrideMetadata(typeof(ContextualGraphLayout), new PropertyMetadata(new ContextualLayoutAlgorithmFactory(), null, LayoutAlgorithmFactory_Coerce)); 40 | } 41 | 42 | protected override ILayoutContext CreateLayoutContext(IDictionary positions, IDictionary sizes) 43 | { 44 | return new ContextualLayoutContext(Graph, SelectedVertex, positions, sizes); 45 | } 46 | 47 | protected override bool CanLayout 48 | { 49 | get 50 | { 51 | return SelectedVertex != null && base.CanLayout; 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/IAnimation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Controls; 3 | 4 | 5 | namespace GraphSharp.Controls 6 | { 7 | public interface IAnimation 8 | { 9 | /// 10 | /// Animates the control of a vertex to a given position. 11 | /// 12 | /// The context of the animation. 13 | /// The control which should be animated to its new position. 14 | /// The new horizontal coordinate. 15 | /// The new vertical coordinate. 16 | /// The duration of the animation. 17 | void Animate( IAnimationContext context, Control control, double x, double y, TimeSpan duration ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/IAnimationContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GraphSharp.Controls 4 | { 5 | public interface IAnimationContext 6 | { 7 | GraphCanvas GraphCanvas { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/ICompoundVertexControl.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace GraphSharp.Controls 4 | { 5 | interface ICompoundVertexControl 6 | { 7 | /// 8 | /// Gets the 'borderthickness' of the control around the inner canvas. 9 | /// 10 | Thickness VertexBorderThickness { get; } 11 | 12 | /// 13 | /// Gets the size of the inner canvas. 14 | /// 15 | Size InnerCanvasSize { get; } 16 | 17 | event RoutedEventHandler Expanded; 18 | event RoutedEventHandler Collapsed; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/ITransition.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System; 3 | 4 | namespace GraphSharp.Controls 5 | { 6 | public interface ITransition 7 | { 8 | /// 9 | /// Runs the transition. 10 | /// 11 | /// The context of the transition. 12 | /// The control which the transition should be run on. 13 | /// The duration of the transition. 14 | void Run( IAnimationContext context, Control control, TimeSpan duration ); 15 | 16 | /// 17 | /// Runs the transition. 18 | /// 19 | /// The context of the transition. 20 | /// The control which the transition should be run on. 21 | /// The duration of the transition. 22 | /// The method that should be called when the transition finished. 23 | void Run( IAnimationContext context, Control control, TimeSpan duration, Action endMethod ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/LayoutMode.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Controls 2 | { 3 | public enum LayoutMode 4 | { 5 | /// 6 | /// Decide about the layout mode automatically. 7 | /// 8 | Automatic, 9 | 10 | /// 11 | /// There should not be any compound vertices. 12 | /// 13 | Simple, 14 | 15 | /// 16 | /// Compound vertices, compound graph. 17 | /// 18 | Compound 19 | } 20 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/PositionChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.Contracts; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Controls 5 | { 6 | public class PositionChangedEventArgs : RoutedEventArgs 7 | { 8 | public double XChange { get; private set; } 9 | public double YChange { get; private set; } 10 | 11 | public PositionChangedEventArgs(RoutedEvent evt, object source, double xChange, double yChange) 12 | : base(evt, source) 13 | { 14 | XChange = xChange; 15 | YChange = yChange; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/PositionChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Controls 7 | { 8 | public delegate void PositionChangedEventHandler(object sender, PositionChangedEventArgs args); 9 | } 10 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/Transitions/FadeInTransition.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Controls.Transitions 2 | { 3 | public class FadeInTransition : FadeTransition 4 | { 5 | public FadeInTransition() 6 | : base( 0.0, 1.0, 1 ) 7 | { 8 | 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/Transitions/FadeOutTransition.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Controls.Transitions 2 | { 3 | public class FadeOutTransition : FadeTransition 4 | { 5 | public FadeOutTransition() 6 | : base( 1.0, 0.0, 1 ) 7 | { 8 | 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/Transitions/FadeTransition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media.Animation; 4 | using System.Windows.Controls; 5 | 6 | namespace GraphSharp.Controls.Transitions 7 | { 8 | public class FadeTransition : TransitionBase 9 | { 10 | private readonly double startOpacity; 11 | private readonly double endOpacity; 12 | private readonly int rounds = 1; 13 | 14 | public FadeTransition( double startOpacity, double endOpacity ) 15 | : this( startOpacity, endOpacity, 2 ) 16 | { 17 | } 18 | 19 | public FadeTransition( double startOpacity, double endOpacity, int rounds ) 20 | { 21 | this.startOpacity = startOpacity; 22 | this.endOpacity = endOpacity; 23 | this.rounds = rounds; 24 | } 25 | 26 | public override void Run( 27 | IAnimationContext context, 28 | Control control, 29 | TimeSpan duration, 30 | Action endMethod ) 31 | { 32 | var storyboard = new Storyboard(); 33 | 34 | DoubleAnimation fadeAnimation; 35 | 36 | if ( rounds > 1 ) 37 | { 38 | fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) ); 39 | fadeAnimation.AutoReverse = true; 40 | fadeAnimation.RepeatBehavior = new RepeatBehavior( rounds - 1 ); 41 | storyboard.Children.Add( fadeAnimation ); 42 | Storyboard.SetTarget( fadeAnimation, control ); 43 | Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) ); 44 | } 45 | 46 | fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) ); 47 | fadeAnimation.BeginTime = TimeSpan.FromMilliseconds( duration.TotalMilliseconds * ( rounds - 1 ) * 2 ); 48 | storyboard.Children.Add( fadeAnimation ); 49 | Storyboard.SetTarget( fadeAnimation, control ); 50 | Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) ); 51 | 52 | if ( endMethod != null ) 53 | storyboard.Completed += ( s, a ) => endMethod( control ); 54 | storyboard.Begin( control ); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Controls/Transitions/TransitionBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GraphSharp.Controls.Transitions 4 | { 5 | public abstract class TransitionBase : ITransition 6 | { 7 | #region ITransition Members 8 | 9 | public void Run( IAnimationContext context, System.Windows.Controls.Control control, TimeSpan duration ) 10 | { 11 | Run( context, control, duration, null ); 12 | } 13 | 14 | public abstract void Run( IAnimationContext context, 15 | System.Windows.Controls.Control control, 16 | TimeSpan duration, 17 | Action endMethod ); 18 | 19 | #endregion 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Converters/CoordinatesToPointConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Data; 3 | using System.Diagnostics; 4 | using System.Windows; 5 | 6 | namespace GraphSharp.Converters 7 | { 8 | public class CoordinatesToPointConverter : IMultiValueConverter 9 | { 10 | public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture ) 11 | { 12 | Debug.Assert( values != null && values.Length == 2, "CoordinatesToPointConverter.Convert should get 2 values as input: X and Y coordinates" ); 13 | 14 | double x = (double)values[0]; 15 | double y = (double)values[1]; 16 | 17 | return new Point( x, y ); 18 | } 19 | 20 | public object[] ConvertBack( object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture ) 21 | { 22 | Debug.Assert( !( value is Point ), "CoordinatesToPointConverter.ConvertBack should get a Point object as input." ); 23 | 24 | var point = (Point)value; 25 | 26 | return new object[] { point.X, point.Y }; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/Converters/PointArrayToString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Windows.Data; 4 | using System.Windows; 5 | 6 | namespace GraphSharp.Converters 7 | { 8 | public class PointArrayToString : IValueConverter 9 | { 10 | #region IValueConverter Members 11 | 12 | public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) 13 | { 14 | var points = value as Point[]; 15 | 16 | if ( points == null ) 17 | return string.Empty; 18 | var sb = new StringBuilder(); 19 | foreach ( var point in points ) 20 | { 21 | sb.AppendLine( point.ToString() ); 22 | } 23 | return sb; 24 | } 25 | 26 | public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | 31 | #endregion 32 | } 33 | } -------------------------------------------------------------------------------- /Source/Graph#.Controls/GraphSharp.Controls.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/GraphSharp.Controls.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GraphSharp.SIL 5 | $version$ 6 | GraphSharp (SIL) 7 | palesz, SIL International 8 | SIL International 9 | Apache-2.0 10 | https://github.com/sillsdev/graphsharp 11 | false 12 | Graph# (SIL) is a graph layout framework. It contains some layout algorithms and a GraphLayout control for WPF applications. This is a fork of the Graph# library. 13 | Copyright 2020 14 | WPF QuickGraph Graph# edge routing graph layout 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/GraphSharp.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#.Controls/GraphSharp.snk -------------------------------------------------------------------------------- /Source/Graph#.Controls/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GraphSharp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Source/Graph#.Controls/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Sample 2 | { 3 | /// 4 | /// Interaction logic for App.xaml 5 | /// 6 | 7 | public partial class App 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/Converters/BoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Sample.Converters 5 | { 6 | public class BoolToVisibilityConverter : IValueConverter 7 | { 8 | #region IValueConverter Members 9 | 10 | public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) 11 | { 12 | bool b = (bool) value; 13 | if (b) 14 | { 15 | return Visibility.Visible; 16 | } 17 | 18 | return Visibility.Collapsed; 19 | } 20 | 21 | public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) 22 | { 23 | throw new System.NotImplementedException(); 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/Converters/DoubleToIntegerConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Data; 3 | 4 | namespace GraphSharp.Sample.Converters 5 | { 6 | public class IntegerToDoubleConverter : IValueConverter 7 | { 8 | #region IValueConverter Members 9 | 10 | public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) 11 | { 12 | double r = (int)value; 13 | return r; 14 | } 15 | 16 | public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) 17 | { 18 | return Math.Round( (double)value ); 19 | } 20 | 21 | #endregion 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/GraphSharp.Sample.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/LayoutManager.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Collections.Generic; 3 | using GraphSharp.Sample.ViewModel; 4 | 5 | namespace GraphSharp.Sample 6 | { 7 | public class LayoutManager : DependencyObject 8 | { 9 | private static LayoutManager instance; 10 | 11 | public static LayoutManager Instance 12 | { 13 | get 14 | { 15 | if (instance == null) 16 | instance = new LayoutManager(); 17 | 18 | return instance; 19 | } 20 | } 21 | 22 | protected LayoutManager() 23 | { 24 | 25 | } 26 | 27 | public void ContinueLayout() 28 | { 29 | foreach (var layout in graphLayouts) 30 | { 31 | layout.ContinueLayout(); 32 | } 33 | } 34 | 35 | public void Relayout() 36 | { 37 | foreach (var layout in graphLayouts) 38 | { 39 | layout.Relayout(); 40 | } 41 | } 42 | 43 | protected readonly HashSet graphLayouts = new HashSet(); 44 | 45 | public static readonly DependencyProperty ManagedLayoutProperty = 46 | DependencyProperty.RegisterAttached("ManagedLayout", typeof(bool), typeof(LayoutManager), new PropertyMetadata(false, ManagedLayout_PropertyChanged)); 47 | 48 | [AttachedPropertyBrowsableForChildren] 49 | public static bool GetManagedLayout(DependencyObject obj) 50 | { 51 | return (bool)obj.GetValue(ManagedLayoutProperty); 52 | } 53 | 54 | public static void SetManagedLayout(DependencyObject obj, bool value) 55 | { 56 | obj.SetValue(ManagedLayoutProperty, value); 57 | } 58 | 59 | protected static void ManagedLayout_PropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) 60 | { 61 | var graphLayout = obj as PocGraphLayout; 62 | if (graphLayout == null) 63 | return; 64 | 65 | if ((bool)e.NewValue) 66 | { 67 | //the layout became managed 68 | Instance.graphLayouts.Add(graphLayout); 69 | graphLayout.Unloaded += GraphLayout_Unloaded; 70 | } 71 | else if ((bool)e.OldValue && (((bool)e.NewValue) == false) && Instance.graphLayouts.Contains(graphLayout)) 72 | { 73 | //the layout became unmanaged 74 | Instance.graphLayouts.Remove(graphLayout); 75 | graphLayout.Unloaded -= GraphLayout_Unloaded; 76 | } 77 | } 78 | 79 | private static void GraphLayout_Unloaded(object s, RoutedEventArgs args) 80 | { 81 | if (s is PocGraphLayout) 82 | Instance.graphLayouts.Remove(s as PocGraphLayout); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | using GraphSharp.Sample.ViewModel; 4 | using System.Windows; 5 | using WPFExtensions.Controls; 6 | 7 | namespace GraphSharp.Sample 8 | { 9 | /// 10 | /// Main window of the Proof of Concept application for the GraphLayout control. 11 | /// 12 | public partial class MainWindow 13 | { 14 | readonly LayoutAnalyzerViewModel analyzerViewModel = new LayoutAnalyzerViewModel(); 15 | 16 | public MainWindow() 17 | { 18 | InitializeComponent(); 19 | 20 | DataContext = analyzerViewModel; 21 | } 22 | 23 | private void NotificationTest_Executed(object sender, ExecutedRoutedEventArgs e) 24 | { 25 | var testWindow = new TestWindow(); 26 | testWindow.Show(); 27 | } 28 | 29 | private void Exit_Executed(object sender, ExecutedRoutedEventArgs e) 30 | { 31 | Application.Current.Shutdown(); 32 | } 33 | 34 | private void ContextualLayoutTest_Executed(object sender, ExecutedRoutedEventArgs e) 35 | { 36 | var window = new TestContextualLayout(analyzerViewModel.SelectedGraphModel.Graph); 37 | window.Show(); 38 | } 39 | 40 | private void CompoundLayoutTest_Executed(object sender, ExecutedRoutedEventArgs e) 41 | { 42 | var window = new TestCompoundLayout(); 43 | window.Show(); 44 | } 45 | 46 | private void AnimatedCompoundLayoutTest_Executed(object sender, ExecutedRoutedEventArgs e) 47 | { 48 | var window = new PlainCompoundLayoutTest(); 49 | window.Show(); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/Model/GraphModel.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Sample.Model 2 | { 3 | public class GraphModel 4 | { 5 | public string Name { get; private set; } 6 | public PocGraph Graph { get; private set; } 7 | 8 | public GraphModel(string name, PocGraph graph) 9 | { 10 | Name = name; 11 | Graph = graph; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/PocEdge.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | using System.Diagnostics; 3 | 4 | namespace GraphSharp.Sample 5 | { 6 | /// 7 | /// A simple identifiable edge. 8 | /// 9 | [DebuggerDisplay( "{Source.ID} -> {Target.ID}" )] 10 | public class PocEdge : Edge 11 | { 12 | public string ID 13 | { 14 | get; 15 | private set; 16 | } 17 | 18 | public PocEdge( string id, PocVertex source, PocVertex target ) 19 | : base( source, target ) 20 | { 21 | ID = id; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/PocGraph.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp.Sample 4 | { 5 | public class PocGraph : BidirectionalGraph 6 | { 7 | public PocGraph() { } 8 | 9 | public PocGraph(bool allowParallelEdges) 10 | : base(allowParallelEdges) { } 11 | 12 | public PocGraph(bool allowParallelEdges, int vertexCapacity) 13 | : base(allowParallelEdges, vertexCapacity) { } 14 | } 15 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/PocSerializeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | // using QuickGraph.Serialization; 3 | // using System.Xml; 4 | 5 | namespace GraphSharp.Sample 6 | { 7 | public static class PocSerializeHelper 8 | { 9 | public static PocGraph LoadGraph( string filename ) 10 | { 11 | ////open the file of the graph 12 | //var reader = XmlReader.Create( filename ); 13 | 14 | ////create the serializer 15 | //var serializer = new GraphMLDeserializer(); 16 | 17 | ////graph where the vertices and edges should be put in 18 | //var pocGraph = new PocGraph(); 19 | 20 | ////deserialize the graph 21 | //serializer.Deserialize( reader, pocGraph, 22 | // id => new PocVertex( id ), 23 | // ( source, target, id ) => new PocEdge( id, source, target ) ); 24 | 25 | //return pocGraph; 26 | throw new NotImplementedException(); 27 | } 28 | 29 | public static void SaveGraph( PocGraph graph, string filename ) 30 | { 31 | ////create the xml writer 32 | //using ( var writer = XmlWriter.Create( filename ) ) 33 | //{ 34 | // var serializer = new GraphMLSerializer(); 35 | 36 | // //serialize the graph 37 | // serializer.Serialize( writer, graph, v => v.ID, e => e.ID ); 38 | //} 39 | throw new NotImplementedException(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/PocVertex.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | namespace GraphSharp.Sample 3 | { 4 | /// 5 | /// A simple identifiable vertex. 6 | /// 7 | [DebuggerDisplay( "{ID}" )] 8 | public class PocVertex 9 | { 10 | public string ID 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public PocVertex( string id ) 17 | { 18 | ID = id; 19 | } 20 | 21 | public override string ToString() 22 | { 23 | return ID; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/PocVertexToLayoutModeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Data; 6 | using GraphSharp.Algorithms.Layout.Compound; 7 | 8 | namespace GraphSharp.Sample 9 | { 10 | public class PocVertexToLayoutModeConverter : IValueConverter 11 | { 12 | #region IValueConverter Members 13 | 14 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 15 | { 16 | var vertex = value as string; 17 | if (vertex == "2" || vertex == "3") 18 | return CompoundVertexInnerLayoutType.Fixed; 19 | else 20 | return CompoundVertexInnerLayoutType.Automatic; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GraphSharp.Sample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("gml")] 29 | public string GraphMLExtension { 30 | get { 31 | return ((string)(this["GraphMLExtension"])); 32 | } 33 | set { 34 | this["GraphMLExtension"] = value; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | gml 7 | 8 | 9 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/Resources/GraphicResources.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 15 8 | 15 9 | 10 | 11 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/RibbonCommands.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/TestContextualLayout.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using GraphSharp.Controls; 3 | using System.Linq; 4 | using System.ComponentModel; 5 | using System.Windows.Controls; 6 | 7 | namespace GraphSharp.Sample 8 | { 9 | public class PocContextualGraphLayout : ContextualGraphLayout { } 10 | 11 | /// 12 | /// Interaction logic for TestContextualLayout.xaml 13 | /// 14 | public partial class TestContextualLayout : INotifyPropertyChanged 15 | { 16 | public PocGraph Graph 17 | { 18 | get; private set; 19 | } 20 | 21 | private PocVertex selectedVertex; 22 | public PocVertex SelectedVertex 23 | { 24 | get 25 | { 26 | return selectedVertex; 27 | } 28 | set 29 | { 30 | selectedVertex = value; 31 | if (PropertyChanged != null) 32 | PropertyChanged(this, new PropertyChangedEventArgs("SelectedVertex")); 33 | } 34 | } 35 | 36 | public TestContextualLayout(PocGraph graph) 37 | { 38 | InitializeComponent(); 39 | 40 | Graph = graph; 41 | SelectedVertex = graph.Vertices.FirstOrDefault(); 42 | DataContext = this; 43 | } 44 | 45 | #region INotifyPropertyChanged Members 46 | 47 | public event PropertyChangedEventHandler PropertyChanged; 48 | 49 | #endregion 50 | 51 | private void SelectedVertexChange_Click(object sender, RoutedEventArgs e) 52 | { 53 | var btn = e.Source as Button; 54 | SelectedVertex = btn.Tag as PocVertex; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/ViewModel/GraphLayoutViewModel.cs: -------------------------------------------------------------------------------- 1 | using GraphSharp.Controls; 2 | using System.ComponentModel; 3 | 4 | namespace GraphSharp.Sample.ViewModel 5 | { 6 | public class PocGraphLayout : GraphLayout { } 7 | 8 | public class GraphLayoutViewModel : INotifyPropertyChanged 9 | { 10 | private string layoutAlgorithmType; 11 | private PocGraph graph; 12 | 13 | public string LayoutAlgorithmType 14 | { 15 | get { return layoutAlgorithmType; } 16 | set 17 | { 18 | if (value != layoutAlgorithmType) 19 | { 20 | layoutAlgorithmType = value; 21 | NotifyChanged("LayoutAlgorithmType"); 22 | } 23 | } 24 | } 25 | 26 | public PocGraph Graph 27 | { 28 | get { return graph; } 29 | set 30 | { 31 | if (value != graph) 32 | { 33 | graph = value; 34 | NotifyChanged("Graph"); 35 | } 36 | } 37 | } 38 | 39 | public event PropertyChangedEventHandler PropertyChanged; 40 | protected void NotifyChanged(string propertyName) 41 | { 42 | if (PropertyChanged != null) 43 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/ViewModel/LayoutAnalyzerViewModel.SampleGraphs.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using GraphSharp.Sample.Model; 3 | 4 | namespace GraphSharp.Sample.ViewModel 5 | { 6 | public partial class LayoutAnalyzerViewModel 7 | { 8 | partial void CreateSampleGraphs() 9 | { 10 | #region SimpleTree 11 | 12 | var graph = new PocGraph(); 13 | 14 | for (int i = 0; i < 8; i++) 15 | { 16 | var v = new PocVertex(i.ToString()); 17 | graph.AddVertex(v); 18 | } 19 | 20 | graph.AddEdge(new PocEdge("0to1", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); 21 | graph.AddEdge(new PocEdge("1to2", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); 22 | graph.AddEdge(new PocEdge("2to3", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(3))); 23 | graph.AddEdge(new PocEdge("2to4", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); 24 | graph.AddEdge(new PocEdge("0to5", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(5))); 25 | graph.AddEdge(new PocEdge("1to7", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(7))); 26 | graph.AddEdge(new PocEdge("4to6", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); 27 | 28 | GraphModels.Add(new GraphModel("Fa", graph)); 29 | 30 | #endregion 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Source/Graph#.Sample/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | gml 15 | 16 | 17 | 18 | 19 | 20 | 21 | gml 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/icons/Block.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/icons/GraphSharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#.Sample/icons/GraphSharp.png -------------------------------------------------------------------------------- /Source/Graph#.Sample/icons/Left.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/icons/Up.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Source/Graph#.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Source/Graph#.Test/GraphHelperTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using QuickGraph; 4 | using GraphSharp; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace GraphSharp.Test 8 | { 9 | /// 10 | /// Summary description for GraphHelperTest 11 | /// 12 | [TestClass] 13 | public class GraphHelperTest 14 | { 15 | BidirectionalGraph> directedGraph; 16 | UndirectedBidirectionalGraph> undirectedGraph; 17 | string one = "one"; 18 | string two = "two"; 19 | string three = "three"; 20 | string four = "four"; 21 | 22 | 23 | public GraphHelperTest() 24 | { 25 | #region create directedGraph 26 | directedGraph = new BidirectionalGraph>( ); 27 | 28 | directedGraph.AddVertex( one ); directedGraph.AddVertex( two ); directedGraph.AddVertex( three ); directedGraph.AddVertex( four ); 29 | directedGraph.AddEdge( new Edge( one, four ) ); 30 | directedGraph.AddEdge( new Edge( one, three ) ); 31 | directedGraph.AddEdge( new Edge( four, two ) ); 32 | directedGraph.AddEdge( new Edge( one, two ) ); 33 | #endregion 34 | 35 | #region create undirected graph 36 | undirectedGraph = new UndirectedBidirectionalGraph>( directedGraph ); 37 | #endregion 38 | } 39 | 40 | [TestMethod] 41 | public void EdgesBetweenDirectedTestOne() 42 | { 43 | List set1 = new List( ); 44 | set1.Add( one ); set1.Add( two ); 45 | 46 | List set2 = new List( ); 47 | set2.Add( three ); set2.Add( four ); 48 | 49 | List> result = directedGraph.GetEdgesBetween( set1, set2 ).ToList(); 50 | 51 | Assert.AreEqual( 2, result.Count ); 52 | Assert.AreEqual( one, result[ 0 ].Source ); 53 | Assert.AreEqual( four, result[ 0 ].Target ); 54 | Assert.AreEqual( one, result[ 1 ].Source ); 55 | Assert.AreEqual( three, result[ 1 ].Target ); 56 | } 57 | 58 | [TestMethod] 59 | public void EdgesBetweenDirectedTestTwo() 60 | { 61 | List set1 = new List( ); 62 | set1.Add( one ); set1.Add( two ); 63 | 64 | List set2 = new List( ); 65 | set2.Add( three ); set2.Add( four ); 66 | 67 | List> result = directedGraph.GetEdgesBetween( set2, set1 ).ToList(); 68 | 69 | Assert.AreEqual( 1, result.Count ); 70 | Assert.AreEqual( four, result[ 0 ].Source ); 71 | Assert.AreEqual( two, result[ 0 ].Target ); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Source/Graph#.Test/GraphSharp.Test.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Source/Graph#.Test/Metrics/IMetricCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using QuickGraph; 6 | using System.Windows; 7 | 8 | namespace Palesz.QuickGraph.Test.Metrics 9 | { 10 | public interface IMetricCalculator 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | /* 15 | * TGraph graph, IDictionary vertexPositions, IDictionary vertexSize, IDictionary edgeRoutes 16 | */ 17 | void Calculate(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Graph#.Test/Metrics/LayoutAreaMetricCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using QuickGraph; 6 | using System.Windows; 7 | 8 | namespace Palesz.QuickGraph.Test.Metrics 9 | { 10 | public class LayoutAreaMetricCalculator : MetricCalculatorBase 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | public LayoutAreaMetricCalculator( TGraph graph, IDictionary vertexPositions, IDictionary vertexSizes, IDictionary edgeRoutes ) 15 | : base( graph, vertexPositions, vertexSizes, edgeRoutes ) { } 16 | 17 | public double Area { get; private set; } 18 | public double Ratio { get; private set; } 19 | 20 | public override void Calculate() 21 | { 22 | Point topLeft = new Point( double.PositiveInfinity, double.PositiveInfinity ); 23 | Point bottomRight = new Point( double.NegativeInfinity, double.NegativeInfinity ); 24 | 25 | foreach ( var v in Graph.Vertices ) 26 | { 27 | Point p = Positions[v]; 28 | Size s = Sizes[v]; 29 | topLeft.X = Math.Min( p.X - s.Width / 2.0, topLeft.X ); 30 | topLeft.Y = Math.Min( p.Y - s.Height / 2.0, topLeft.Y ); 31 | 32 | bottomRight.X = Math.Max( p.X + s.Width / 2.0, bottomRight.X ); 33 | bottomRight.Y = Math.Max( p.Y + s.Height / 2.0, bottomRight.Y ); 34 | } 35 | 36 | foreach ( var e in Graph.Edges ) 37 | { 38 | Point[] routePoints = null; 39 | if ( !EdgeRoutes.TryGetValue( e, out routePoints ) || routePoints == null || routePoints.Length == 0) 40 | continue; 41 | 42 | for ( int i = 0; i < routePoints.Length; i++ ) 43 | { 44 | Point p = routePoints[i]; 45 | topLeft.X = Math.Min( p.X, topLeft.X ); 46 | topLeft.Y = Math.Min( p.Y, topLeft.Y ); 47 | 48 | bottomRight.X = Math.Max( p.X, bottomRight.X ); 49 | bottomRight.Y = Math.Max( p.Y, bottomRight.Y ); 50 | } 51 | } 52 | 53 | Vector layoutAreaSize = bottomRight - topLeft; 54 | 55 | Area = layoutAreaSize.LengthSquared; 56 | Ratio = layoutAreaSize.X / layoutAreaSize.Y; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Source/Graph#.Test/Metrics/MetricCalculatorBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using QuickGraph; 7 | 8 | namespace Palesz.QuickGraph.Test.Metrics 9 | { 10 | public abstract class MetricCalculatorBase : IMetricCalculator 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | public TGraph Graph { get; private set; } 15 | public IDictionary Positions { get; private set; } 16 | public IDictionary Sizes { get; private set; } 17 | public IDictionary EdgeRoutes { get; private set; } 18 | 19 | public MetricCalculatorBase( TGraph graph, IDictionary vertexPositions, IDictionary vertexSizes, IDictionary edgeRoutes ) 20 | { 21 | Graph = graph; 22 | Positions = vertexPositions; 23 | Sizes = vertexSizes; 24 | EdgeRoutes = edgeRoutes; 25 | } 26 | 27 | public abstract void Calculate(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Graph#.Test/Metrics/OverlapMetricCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using QuickGraph; 7 | 8 | namespace Palesz.QuickGraph.Test.Metrics 9 | { 10 | public class OverlapMetricCalculator : MetricCalculatorBase 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | public OverlapMetricCalculator( TGraph graph, IDictionary vertexPositions, IDictionary vertexSizes, IDictionary edgeRoutes ) 15 | : base( graph, vertexPositions, vertexSizes, edgeRoutes ) { } 16 | 17 | public int OverlapCount { get; private set; } 18 | public double OverlappedArea { get; private set; } 19 | 20 | public override void Calculate() 21 | { 22 | var vertices = Graph.Vertices.ToArray(); 23 | for ( int i = 0; i < vertices.Length - 1; i++ ) 24 | { 25 | for ( int j = i + 1; j < vertices.Length; j++ ) 26 | { 27 | var v1 = vertices[i]; 28 | var v2 = vertices[j]; 29 | 30 | var p1 = Positions[v1]; 31 | var p2 = Positions[v2]; 32 | 33 | var s1 = Sizes[v1]; 34 | var s2 = Sizes[v2]; 35 | 36 | Rect r1 = new Rect( p1.X - s1.Width / 2, p1.Y - s1.Height / 2, p1.X + s1.Width / 2, p1.Y + s1.Height / 2 ); 37 | Rect r2 = new Rect( p2.X - s1.Width / 2, p2.Y - s1.Height / 2, p2.X + s1.Width / 2, p2.Y + s1.Height / 2 ); 38 | 39 | //check whether the vertices overlaps or not 40 | r1.Intersect( r2 ); 41 | 42 | if ( r1.Width > 0 && r1.Height > 0 ) 43 | { 44 | OverlapCount++; 45 | OverlappedArea += r1.Width * r1.Height; 46 | } 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Source/Graph#.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Palesz.QuickGraph.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Palesz.QuickGraph.Test")] 13 | [assembly: AssemblyCopyright("Copyright © 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM componenets. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("80f44b91-648f-45d3-a032-08d5f76e1ce4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.2.0")] 35 | [assembly: AssemblyFileVersion("1.0.2.0")] 36 | -------------------------------------------------------------------------------- /Source/Graph#.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/BundleEdgeRoutingParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.EdgeRouting 2 | { 3 | public class BundleEdgeRoutingParameters : EdgeRoutingParameters 4 | { 5 | private double _vertexMargin; 6 | private double _inkCoefficient = 1; 7 | private double _lengthCoefficient = 500; 8 | 9 | public double VertexMargin 10 | { 11 | get { return _vertexMargin; } 12 | set 13 | { 14 | _vertexMargin = value; 15 | NotifyChanged("VertexMargin"); 16 | } 17 | } 18 | 19 | public double InkCoefficient 20 | { 21 | get { return _inkCoefficient; } 22 | set 23 | { 24 | _inkCoefficient = value; 25 | NotifyChanged("InkCoefficient"); 26 | } 27 | } 28 | 29 | public double LengthCoefficient 30 | { 31 | get { return _lengthCoefficient; } 32 | set 33 | { 34 | _lengthCoefficient = value; 35 | NotifyChanged("LengthCoefficient"); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/EdgeRoutingAlgorithmBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using QuickGraph.Algorithms; 4 | using System.Windows; 5 | 6 | namespace GraphSharp.Algorithms.EdgeRouting 7 | { 8 | public abstract class EdgeRoutingAlgorithmBase : AlgorithmBase, IEdgeRoutingAlgorithm 9 | where TVertex : class 10 | where TEdge : IEdge 11 | where TGraph : IVertexAndEdgeListGraph 12 | { 13 | protected IDictionary vertexPositions; 14 | 15 | /// 16 | /// Gets or sets the routing points of the edges. 17 | /// 18 | public IDictionary EdgeRoutes 19 | { 20 | get; 21 | private set; 22 | } 23 | 24 | public EdgeRoutingAlgorithmBase(TGraph visitedGraph, IDictionary vertexPositions) 25 | : base(visitedGraph) 26 | { 27 | this.vertexPositions = vertexPositions; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/EdgeRoutingParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.EdgeRouting 2 | { 3 | public class EdgeRoutingParameters : IEdgeRoutingParameters 4 | { 5 | public object Clone() 6 | { 7 | return this.MemberwiseClone(); 8 | } 9 | 10 | protected void NotifyChanged( string propertyName ) 11 | { 12 | var handler = PropertyChanged; 13 | if (handler != null) 14 | handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); 15 | } 16 | 17 | public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 18 | } 19 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/IEdgeRoutingAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph.Algorithms; 3 | using QuickGraph; 4 | using System.Windows; 5 | 6 | namespace GraphSharp.Algorithms.EdgeRouting 7 | { 8 | public interface IEdgeRoutingAlgorithm : IAlgorithm 9 | where TEdge : IEdge 10 | where TGraph : IVertexAndEdgeListGraph 11 | { 12 | IDictionary EdgeRoutes { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/IEdgeRoutingAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using GraphSharp.Algorithms.Layout; 3 | using QuickGraph; 4 | 5 | namespace GraphSharp.Algorithms.EdgeRouting 6 | { 7 | public interface IEdgeRoutingAlgorithmFactory 8 | where TVertex : class 9 | where TEdge : IEdge 10 | where TGraph : class, IBidirectionalGraph 11 | { 12 | /// 13 | /// List of the available algorithms. 14 | /// 15 | IEnumerable AlgorithmTypes { get; } 16 | 17 | IEdgeRoutingAlgorithm CreateAlgorithm( string newAlgorithmType, ILayoutContext context, IEdgeRoutingParameters parameters); 18 | 19 | IEdgeRoutingParameters CreateParameters( string algorithmType, IEdgeRoutingParameters oldParameters ); 20 | 21 | bool IsValidAlgorithm( string algorithmType ); 22 | 23 | string GetAlgorithmType( IEdgeRoutingAlgorithm algorithm ); 24 | } 25 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/IEdgeRoutingParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.EdgeRouting 2 | { 3 | public interface IEdgeRoutingParameters : IAlgorithmParameters 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/ObstacleSegment.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.EdgeRouting 2 | { 3 | internal class ObstacleSegment 4 | { 5 | private readonly Obstacle _obstacle; 6 | private readonly RotationTreeNode _point1; 7 | private readonly RotationTreeNode _point2; 8 | 9 | public ObstacleSegment(Obstacle obstacle, RotationTreeNode point1, RotationTreeNode point2) 10 | { 11 | _obstacle = obstacle; 12 | _point1 = point1; 13 | _point1.Segments.Add(this); 14 | _point2 = point2; 15 | _point2.Segments.Add(this); 16 | } 17 | 18 | public RotationTreeNode Point1 19 | { 20 | get { return _point1; } 21 | } 22 | 23 | public RotationTreeNode Point2 24 | { 25 | get { return _point2; } 26 | } 27 | 28 | public Obstacle Obstacle 29 | { 30 | get { return _obstacle; } 31 | } 32 | 33 | public bool Contains(RotationTreeNode p) 34 | { 35 | return _point1 == p || _point2 == p; 36 | } 37 | 38 | public RotationTreeNode GetOtherPoint(RotationTreeNode p) 39 | { 40 | return _point1 == p ? _point2 : _point1; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/PointVertex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Algorithms.EdgeRouting 5 | { 6 | /// 7 | /// We use a wrapper class for vertices instead of just the Point class, because 8 | /// Quickgraph requires that a vertex implement IEquatable for some operations. 9 | /// 10 | public class PointVertex : IEquatable 11 | { 12 | private readonly Point _point; 13 | 14 | public PointVertex(Point point) 15 | { 16 | _point = point; 17 | } 18 | 19 | public Point Point 20 | { 21 | get { return _point; } 22 | } 23 | 24 | public override bool Equals(object obj) 25 | { 26 | var otherPoint = obj as PointVertex; 27 | return otherPoint != null && Equals(otherPoint); 28 | } 29 | 30 | public bool Equals(PointVertex other) 31 | { 32 | return other != null && _point == other._point; 33 | } 34 | 35 | public override int GetHashCode() 36 | { 37 | return _point.GetHashCode(); 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return _point.ToString(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/EdgeRouting/StandardEdgeRoutingAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using GraphSharp.Algorithms.Layout; 5 | using QuickGraph; 6 | 7 | namespace GraphSharp.Algorithms.EdgeRouting 8 | { 9 | public class StandardEdgeRoutingAlgorithmFactory : IEdgeRoutingAlgorithmFactory 10 | where TVertex : class 11 | where TEdge : IEdge 12 | where TGraph : class, IBidirectionalGraph 13 | { 14 | public IEdgeRoutingAlgorithm CreateAlgorithm(string newAlgorithmType, ILayoutContext context, IEdgeRoutingParameters parameters) 15 | { 16 | switch (newAlgorithmType) 17 | { 18 | case "Bundle": 19 | return new BundleEdgeRoutingAlgorithm(context.Graph, context.Positions, context.Sizes, parameters as BundleEdgeRoutingParameters); 20 | } 21 | return null; 22 | } 23 | 24 | public IEdgeRoutingParameters CreateParameters(string algorithmType, IEdgeRoutingParameters oldParameters) 25 | { 26 | switch (algorithmType) 27 | { 28 | case "Bundle": 29 | return CreateNewParameter(oldParameters); 30 | } 31 | return null; 32 | } 33 | 34 | public bool IsValidAlgorithm(string algorithmType) 35 | { 36 | return AlgorithmTypes.Contains(algorithmType); 37 | } 38 | 39 | public string GetAlgorithmType(IEdgeRoutingAlgorithm algorithm) 40 | { 41 | if (algorithm == null) 42 | return string.Empty; 43 | 44 | int index = algorithm.GetType().Name.IndexOf("EdgeRoutingAlgorithm", StringComparison.Ordinal); 45 | if (index == -1) 46 | return string.Empty; 47 | 48 | string algoType = algorithm.GetType().Name; 49 | return algoType.Substring(0, algoType.Length - index); 50 | } 51 | 52 | public IEnumerable AlgorithmTypes 53 | { 54 | get { return new[] {"Bundle"}; } 55 | } 56 | 57 | public static TParam CreateNewParameter(IEdgeRoutingParameters oldParameters) where TParam : class, IEdgeRoutingParameters, new() 58 | { 59 | var parameters = oldParameters as TParam; 60 | if (parameters != null) 61 | return (TParam) parameters.Clone(); 62 | return new TParam(); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/FactoryHelper.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms 2 | { 3 | public static class FactoryHelper 4 | { 5 | public static TParam CreateNewParameter(this IAlgorithmParameters oldParameters) 6 | where TParam : class, IAlgorithmParameters, new() 7 | { 8 | return !(oldParameters is TParam) 9 | ? new TParam() : 10 | (TParam)(oldParameters as TParam).Clone(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/HighlightAlgorithmBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Diagnostics.Contracts; 3 | using QuickGraph; 4 | using System.Diagnostics; 5 | 6 | namespace GraphSharp.Algorithms.Highlight 7 | { 8 | public abstract class HighlightAlgorithmBase : IHighlightAlgorithm 9 | where TVertex : class 10 | where TEdge : IEdge 11 | where TGraph : class, IBidirectionalGraph 12 | where TParameters : class, IHighlightParameters 13 | { 14 | public IHighlightController Controller { get; private set; } 15 | 16 | IHighlightParameters IHighlightAlgorithm.Parameters 17 | { 18 | get { return Parameters; } 19 | } 20 | 21 | public TParameters Parameters { get; private set; } 22 | 23 | protected HighlightAlgorithmBase( 24 | IHighlightController controller, 25 | IHighlightParameters parameters ) 26 | { 27 | Controller = controller; 28 | TrySetParameters( parameters ); 29 | } 30 | 31 | public abstract void ResetHighlight(); 32 | public abstract bool OnVertexHighlighting( TVertex vertex ); 33 | public abstract bool OnVertexHighlightRemoving( TVertex vertex ); 34 | public abstract bool OnEdgeHighlighting( TEdge edge ); 35 | public abstract bool OnEdgeHighlightRemoving( TEdge edge ); 36 | 37 | public bool IsParametersSettable( IHighlightParameters parameters ) 38 | { 39 | return parameters != null && parameters is TParameters; 40 | } 41 | 42 | public bool TrySetParameters( IHighlightParameters parameters ) 43 | { 44 | if ( IsParametersSettable( parameters ) ) 45 | { 46 | if ( Parameters != null ) 47 | Parameters.PropertyChanged -= OnParameterPropertyChanged; 48 | Parameters = (TParameters)parameters; 49 | if ( Parameters != null ) 50 | Parameters.PropertyChanged += OnParameterPropertyChanged; 51 | return true; 52 | } 53 | return false; 54 | } 55 | 56 | protected virtual void OnParametersChanged() 57 | { 58 | this.ResetHighlight(); 59 | } 60 | 61 | private void OnParameterPropertyChanged( object sender, PropertyChangedEventArgs e ) 62 | { 63 | OnParametersChanged(); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/HighlightContext.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp.Algorithms.Highlight 4 | { 5 | public class HighlightContext : IHighlightContext 6 | where TVertex : class 7 | where TEdge : IEdge 8 | where TGraph : class, IBidirectionalGraph 9 | { 10 | public TGraph Graph 11 | { 12 | get; private set; 13 | } 14 | 15 | public HighlightContext(TGraph graph) 16 | { 17 | this.Graph = graph; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/HighlightParameterBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace GraphSharp.Algorithms.Highlight 4 | { 5 | public class HighlightParameterBase : IHighlightParameters 6 | { 7 | #region ICloneable Members 8 | 9 | public object Clone() 10 | { 11 | return MemberwiseClone(); 12 | } 13 | 14 | #endregion 15 | 16 | #region INotifyPropertyChanged Members 17 | 18 | public event PropertyChangedEventHandler PropertyChanged; 19 | 20 | protected void OnPropertyChanged( string propertyName ) 21 | { 22 | var handler = PropertyChanged; 23 | if (handler != null) 24 | handler(this, new PropertyChangedEventArgs(propertyName)); 25 | } 26 | 27 | #endregion 28 | } 29 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/IHighlightAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp.Algorithms.Highlight 4 | { 5 | public interface IHighlightAlgorithm 6 | where TVertex : class 7 | where TEdge : IEdge 8 | where TGraph : class, IBidirectionalGraph 9 | { 10 | IHighlightParameters Parameters { get; } 11 | 12 | /// 13 | /// Reset the whole highlight. 14 | /// 15 | void ResetHighlight(); 16 | 17 | bool OnVertexHighlighting( TVertex vertex ); 18 | bool OnVertexHighlightRemoving( TVertex vertex ); 19 | bool OnEdgeHighlighting( TEdge edge ); 20 | bool OnEdgeHighlightRemoving( TEdge edge ); 21 | 22 | bool IsParametersSettable(IHighlightParameters parameters); 23 | bool TrySetParameters(IHighlightParameters parameters); 24 | } 25 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/IHighlightAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Highlight 5 | { 6 | public interface IHighlightAlgorithmFactory 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : class, IBidirectionalGraph 10 | { 11 | IEnumerable HighlightModes { get; } 12 | bool IsValidMode( string mode ); 13 | 14 | IHighlightAlgorithm CreateAlgorithm( 15 | string highlightMode, 16 | IHighlightContext context, 17 | IHighlightController controller, 18 | IHighlightParameters parameters ); 19 | 20 | IHighlightParameters CreateParameters( string highlightMode, IHighlightParameters oldParameters ); 21 | 22 | string GetHighlightMode( IHighlightAlgorithm algorithm ); 23 | } 24 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/IHighlightContext.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp.Algorithms.Highlight 4 | { 5 | public interface IHighlightContext 6 | where TEdge : IEdge 7 | where TGraph : IVertexAndEdgeListGraph 8 | { 9 | TGraph Graph { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/IHighlightController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Highlight 5 | { 6 | public interface IHighlightController 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : class, IBidirectionalGraph 10 | { 11 | TGraph Graph { get; } 12 | 13 | IEnumerable HighlightedVertices { get; } 14 | IEnumerable SemiHighlightedVertices { get; } 15 | IEnumerable HighlightedEdges { get; } 16 | IEnumerable SemiHighlightedEdges { get; } 17 | 18 | bool IsHighlightedVertex( TVertex vertex ); 19 | bool IsHighlightedVertex( TVertex vertex, out object highlightInfo ); 20 | bool IsSemiHighlightedVertex( TVertex vertex ); 21 | bool IsSemiHighlightedVertex( TVertex vertex, out object semiHighlightInfo ); 22 | bool IsHighlightedEdge( TEdge edge ); 23 | bool IsHighlightedEdge( TEdge edge, out object highlightInfo ); 24 | bool IsSemiHighlightedEdge( TEdge edge ); 25 | bool IsSemiHighlightedEdge( TEdge edge, out object semiHighlightInfo ); 26 | 27 | void HighlightVertex( TVertex vertex, object highlightInfo ); 28 | void SemiHighlightVertex( TVertex vertex, object semiHighlightInfo ); 29 | void HighlightEdge( TEdge edge, object highlightInfo ); 30 | void SemiHighlightEdge( TEdge edge, object semiHighlightInfo ); 31 | 32 | void RemoveHighlightFromVertex( TVertex vertex ); 33 | void RemoveSemiHighlightFromVertex( TVertex vertex ); 34 | void RemoveHighlightFromEdge( TEdge edge ); 35 | void RemoveSemiHighlightFromEdge( TEdge edge ); 36 | } 37 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/IHighlightParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Highlight 2 | { 3 | public interface IHighlightParameters : IAlgorithmParameters 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/StandardHighlightAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using QuickGraph; 5 | 6 | namespace GraphSharp.Algorithms.Highlight 7 | { 8 | public class StandardHighlightAlgorithmFactory : IHighlightAlgorithmFactory 9 | where TVertex : class 10 | where TEdge : IEdge 11 | where TGraph : class, IBidirectionalGraph 12 | { 13 | public IEnumerable HighlightModes 14 | { 15 | get { return new[] {"Simple", "Hierarchical", "Undirected"}; } 16 | } 17 | 18 | public bool IsValidMode( string mode ) 19 | { 20 | return string.IsNullOrEmpty( mode ) || HighlightModes.Contains( mode ); 21 | } 22 | 23 | public IHighlightAlgorithm CreateAlgorithm( 24 | string highlightMode, 25 | IHighlightContext context, 26 | IHighlightController controller, 27 | IHighlightParameters parameters ) 28 | { 29 | switch (highlightMode) 30 | { 31 | case "Simple": 32 | return new SimpleHighlightAlgorithm(controller, parameters); 33 | case "Hierarchical": 34 | return new HierarchicalHighlightAlgorithm(controller, parameters); 35 | case "Undirected": 36 | return new UndirectedHighlightAlgorithm(controller, parameters as UndirectedHighlightParameters); 37 | default: 38 | return null; 39 | } 40 | } 41 | 42 | public IHighlightParameters CreateParameters( string highlightMode, IHighlightParameters oldParameters ) 43 | { 44 | switch (highlightMode) 45 | { 46 | case "Simple": 47 | return new HighlightParameterBase(); 48 | case "Hierarchical": 49 | return new HighlightParameterBase(); 50 | case "Undirected": 51 | return oldParameters.CreateNewParameter(); 52 | default: 53 | return new HighlightParameterBase(); 54 | } 55 | } 56 | 57 | public string GetHighlightMode( IHighlightAlgorithm algorithm ) 58 | { 59 | if (algorithm == null) 60 | return string.Empty; 61 | 62 | int index = algorithm.GetType().Name.IndexOf("HighlightAlgorithm", StringComparison.Ordinal); 63 | if (index == -1) 64 | return string.Empty; 65 | 66 | string algoType = algorithm.GetType().Name; 67 | return algoType.Substring(0, algoType.Length - index); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Highlight/UndirectedHighlightParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Highlight 2 | { 3 | public class UndirectedHighlightParameters : HighlightParameterBase 4 | { 5 | private double _weightFilter; 6 | 7 | public double WeightFilter 8 | { 9 | get { return _weightFilter; } 10 | set 11 | { 12 | _weightFilter = value; 13 | OnPropertyChanged("WeightFilter"); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/IAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QuickGraph.Algorithms; 3 | 4 | namespace GraphSharp.Algorithms 5 | { 6 | /// 7 | /// Simple algorithm interface which is not connected to any graph. 8 | /// 9 | public interface IAlgorithm 10 | { 11 | object SyncRoot { get;} 12 | ComputationState State { get;} 13 | 14 | void Compute(); 15 | void Abort(); 16 | 17 | event EventHandler StateChanged; 18 | event EventHandler Started; 19 | event EventHandler Finished; 20 | event EventHandler Aborted; 21 | } 22 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/IAlgorithmParameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace GraphSharp.Algorithms 5 | { 6 | public interface IAlgorithmParameters : ICloneable, INotifyPropertyChanged 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/CompoundLayoutContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using QuickGraph; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Compound 6 | { 7 | public class CompoundLayoutContext 8 | : LayoutContext, ICompoundLayoutContext 9 | where TEdge : IEdge 10 | where TGraph : class, IBidirectionalGraph 11 | { 12 | public CompoundLayoutContext( 13 | TGraph graph, 14 | IDictionary positions, 15 | IDictionary sizes, 16 | LayoutMode mode, 17 | IDictionary vertexBorders, 18 | IDictionary layoutTypes) 19 | : base(graph, positions, sizes, mode) 20 | { 21 | VertexBorders = vertexBorders; 22 | LayoutTypes = layoutTypes; 23 | } 24 | 25 | public IDictionary VertexBorders { get; private set; } 26 | public IDictionary LayoutTypes { get; private set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/CompoundLayoutIterationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Compound 6 | { 7 | public class CompoundLayoutIterationEventArgs 8 | : LayoutIterationEventArgs, ICompoundLayoutIterationEventArgs 9 | where TVertex : class 10 | where TEdge : IEdge 11 | { 12 | public CompoundLayoutIterationEventArgs( 13 | int iteration, 14 | double statusInPercent, 15 | string message, 16 | IDictionary vertexPositions, 17 | IDictionary vertexAngles, 18 | IDictionary innerCanvasSizes) 19 | : base(iteration, statusInPercent, message, vertexPositions, vertexAngles) 20 | { 21 | InnerCanvasSizes = innerCanvasSizes; 22 | } 23 | 24 | #region ICompoundLayoutIterationEventArgs Members 25 | 26 | public IDictionary InnerCanvasSizes 27 | { 28 | get; private set; 29 | } 30 | 31 | #endregion 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/CompoundVertexInnerLayoutType.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout.Compound 2 | { 3 | public enum CompoundVertexInnerLayoutType 4 | { 5 | Automatic, 6 | ContextFree, 7 | Contextual, 8 | Fixed 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/ICompoundLayoutAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using QuickGraph; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Compound 6 | { 7 | public interface ICompoundLayoutAlgorithm : ILayoutAlgorithm 8 | where TVertex : class 9 | where TEdge : IEdge 10 | where TGraph : IBidirectionalGraph 11 | { 12 | IDictionary InnerCanvasSizes { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/ICompoundLayoutContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Compound 6 | { 7 | public interface ICompoundLayoutContext : ILayoutContext 8 | where TEdge : IEdge 9 | where TGraph : IBidirectionalGraph 10 | { 11 | IDictionary VertexBorders { get; } 12 | IDictionary LayoutTypes { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/ICompoundLayoutIterationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Algorithms.Layout.Compound 5 | { 6 | public interface ICompoundLayoutIterationEventArgs 7 | : ILayoutIterationEventArgs 8 | where TVertex : class 9 | { 10 | IDictionary InnerCanvasSizes { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/TestingCompoundLayoutIterationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using QuickGraph; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Compound 6 | { 7 | public class TestingCompoundLayoutIterationEventArgs 8 | : CompoundLayoutIterationEventArgs, ILayoutInfoIterationEventArgs 9 | where TVertex : class 10 | where TEdge : IEdge 11 | { 12 | private IDictionary vertexInfos; 13 | 14 | public Point GravitationCenter { get; private set; } 15 | 16 | public TestingCompoundLayoutIterationEventArgs( 17 | int iteration, 18 | double statusInPercent, 19 | string message, 20 | IDictionary vertexPositions, 21 | IDictionary vertexAngles, 22 | IDictionary innerCanvasSizes, 23 | IDictionary vertexInfos, 24 | Point gravitationCenter) 25 | : base(iteration, statusInPercent, message, vertexPositions, vertexAngles, innerCanvasSizes) 26 | { 27 | this.vertexInfos = vertexInfos; 28 | GravitationCenter = gravitationCenter; 29 | } 30 | 31 | public override object GetVertexInfo(TVertex vertex) 32 | { 33 | TVertexInfo info; 34 | if (vertexInfos.TryGetValue(vertex, out info)) 35 | return info; 36 | 37 | return null; 38 | } 39 | 40 | public IDictionary VertexInfos 41 | { 42 | get { return vertexInfos; } 43 | } 44 | 45 | public IDictionary EdgeInfos 46 | { 47 | get { return null; } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Compound/TestingCompoundVertexInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace GraphSharp.Algorithms.Layout.Compound 4 | { 5 | public class TestingCompoundVertexInfo 6 | { 7 | public TestingCompoundVertexInfo(Vector springForce, Vector repulsionForce, Vector gravityForce, Vector applicationForce) 8 | { 9 | SpringForce = springForce; 10 | RepulsionForce = repulsionForce; 11 | GravityForce = gravityForce; 12 | ApplicationForce = applicationForce; 13 | } 14 | 15 | public Vector SpringForce { get; set; } 16 | public Vector RepulsionForce { get; set; } 17 | public Vector GravityForce { get; set; } 18 | public Vector ApplicationForce { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Contextual/ContextualLayoutContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout.Contextual 6 | { 7 | public class ContextualLayoutContext : LayoutContext 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | public TVertex SelectedVertex { get; private set; } 12 | 13 | public ContextualLayoutContext(TGraph graph, TVertex selectedVertex, IDictionary positions, IDictionary sizes) 14 | : base(graph, positions, sizes, LayoutMode.Simple) 15 | { 16 | SelectedVertex = selectedVertex; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Contextual/IContextualLayoutAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp.Algorithms.Layout.Contextual 4 | { 5 | public interface IContextualLayoutAlgorithmFactory : ILayoutAlgorithmFactory 6 | where TVertex : class 7 | where TEdge : IEdge 8 | where TGraph : class, IBidirectionalGraph 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Contextual/RadialTreeLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout.Contextual 2 | { 3 | public enum BranchLengthScaling 4 | { 5 | MinimizeLabelOverlapAverage, 6 | MinimizeLabelOverlapMinimum, 7 | FixedMinimumLength 8 | } 9 | 10 | public class RadialTreeLayoutParameters : LayoutParametersBase 11 | { 12 | private BranchLengthScaling _branchLengthScaling; 13 | private double _minLen; 14 | 15 | public RadialTreeLayoutParameters() 16 | { 17 | _minLen = 10; 18 | } 19 | 20 | public BranchLengthScaling BranchLengthScaling 21 | { 22 | get { return _branchLengthScaling; } 23 | set 24 | { 25 | _branchLengthScaling = value; 26 | NotifyPropertyChanged("BranchLengthScaling"); 27 | } 28 | } 29 | 30 | public double MinimumLength 31 | { 32 | get { return _minLen; } 33 | set 34 | { 35 | _minLen = value; 36 | NotifyPropertyChanged("MinimumLength"); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph.Algorithms; 3 | using QuickGraph; 4 | using System.Windows; 5 | 6 | namespace GraphSharp.Algorithms.Layout 7 | { 8 | public delegate void LayoutIterationEndedEventHandler( object sender, ILayoutIterationEventArgs e ) 9 | where TVertex : class; 10 | 11 | /// 12 | /// Reports the progress of the layout. 13 | /// 14 | /// The sender. 15 | /// The status of the progress in percent. 16 | public delegate void ProgressChangedEventHandler(object sender, double percent); 17 | 18 | public interface ILayoutAlgorithm : ILayoutAlgorithm 19 | where TVertex : class 20 | where TEdge : IEdge 21 | where TGraph : IVertexAndEdgeListGraph 22 | { 23 | /// 24 | /// Extra informations, calculated by the layout 25 | /// 26 | IDictionary VertexInfos { get; } 27 | 28 | /// 29 | /// Extra informations, calculated by the layout 30 | /// 31 | IDictionary EdgeInfos { get; } 32 | } 33 | 34 | public interface ILayoutAlgorithm : IAlgorithm 35 | where TVertex : class 36 | where TEdge : IEdge 37 | where TGraph : IVertexAndEdgeListGraph 38 | { 39 | IDictionary VertexPositions { get; } 40 | 41 | IDictionary VertexAngles { get; } 42 | 43 | /// 44 | /// Returns with the extra layout information of the vertex (or null). 45 | /// 46 | object GetVertexInfo( TVertex vertex ); 47 | 48 | /// 49 | /// Returns with the extra layout information of the edge (or null). 50 | /// 51 | object GetEdgeInfo( TEdge edge ); 52 | 53 | event LayoutIterationEndedEventHandler IterationEnded; 54 | 55 | event ProgressChangedEventHandler ProgressChanged; 56 | } 57 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Layout 5 | { 6 | public interface ILayoutAlgorithmFactory 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : class, IBidirectionalGraph 10 | { 11 | IEnumerable AlgorithmTypes { get; } 12 | 13 | /// 14 | /// Creates a new algorithm specified by the newAlgorithmType parameter. 15 | /// 16 | /// The identifier of the new layout algorithm. 17 | /// 18 | /// 19 | /// The new layout algorithm object. 20 | ILayoutAlgorithm CreateAlgorithm( string newAlgorithmType, ILayoutContext context, ILayoutParameters parameters ); 21 | 22 | ILayoutParameters CreateParameters( string algorithmType, ILayoutParameters oldParameters ); 23 | 24 | bool IsValidAlgorithm( string algorithmType ); 25 | 26 | /// 27 | /// Gets the type of the algorithm (usually the name of the algorithm which identifies the algorithm). 28 | /// 29 | /// The layout algorithm object. 30 | /// The identified of the algorithm. 31 | string GetAlgorithmType( ILayoutAlgorithm algorithm ); 32 | 33 | bool NeedEdgeRouting( string algorithmType ); 34 | 35 | bool NeedOverlapRemoval( string algorithmType ); 36 | } 37 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout 6 | { 7 | public interface ILayoutContext 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | IDictionary Positions { get; } 12 | IDictionary Sizes { get; } 13 | TGraph Graph { get; } 14 | 15 | LayoutMode Mode { get; } 16 | } 17 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutInfoIterationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Layout 5 | { 6 | public interface ILayoutInfoIterationEventArgs 7 | : ILayoutIterationEventArgs 8 | where TVertex : class 9 | where TEdge : IEdge 10 | { 11 | object GetVertexInfo(TVertex vertex); 12 | 13 | object GetEdgeInfo(TEdge edge); 14 | } 15 | 16 | public interface ILayoutInfoIterationEventArgs 17 | : ILayoutInfoIterationEventArgs 18 | where TVertex : class 19 | where TEdge : IEdge 20 | { 21 | IDictionary VertexInfos { get; } 22 | IDictionary EdgeInfos { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutIterationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Algorithms.Layout 5 | { 6 | public interface ILayoutIterationEventArgs 7 | where TVertex : class 8 | { 9 | /// 10 | /// Represent the status of the layout algorithm in percent. 11 | /// 12 | double StatusInPercent { get; } 13 | 14 | /// 15 | /// If the user sets this value to true, the algorithm aborts ASAP. 16 | /// 17 | bool Abort { get; set; } 18 | 19 | /// 20 | /// Number of the actual iteration. 21 | /// 22 | int Iteration { get; } 23 | 24 | /// 25 | /// Message, textual representation of the status of the algorithm. 26 | /// 27 | string Message { get; } 28 | 29 | IDictionary VertexPositions { get; } 30 | 31 | IDictionary VertexAngles { get; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/ILayoutParameters.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GraphSharp.Algorithms.Layout 3 | { 4 | public interface ILayoutParameters : IAlgorithmParameters 5 | { 6 | } 7 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/IParameterizedLayoutAlgorithm.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout 2 | { 3 | public interface IParameterizedLayoutAlgorithm 4 | { 5 | ILayoutParameters GetParameters(); 6 | } 7 | 8 | public interface IParameterizedLayoutAlgorithm : IParameterizedLayoutAlgorithm 9 | where TParam : ILayoutParameters 10 | { 11 | TParam Parameters { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/LayoutContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout 6 | { 7 | public class LayoutContext : ILayoutContext 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | public IDictionary Positions { get; private set; } 12 | 13 | public IDictionary Sizes { get; private set; } 14 | 15 | public TGraph Graph { get; private set; } 16 | 17 | public LayoutMode Mode { get; private set; } 18 | 19 | public LayoutContext(TGraph graph, IDictionary positions, IDictionary sizes, LayoutMode mode) 20 | { 21 | Graph = graph; 22 | Positions = positions; 23 | Sizes = sizes; 24 | Mode = mode; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/LayoutDirection.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout 2 | { 3 | public enum LayoutDirection 4 | { 5 | LeftToRight = 0, 6 | TopToBottom = 1, 7 | RightToLeft = 2, 8 | BottomToTop = 3 9 | } 10 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/LayoutMode.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout 2 | { 3 | public enum LayoutMode 4 | { 5 | /// 6 | /// Simple layout mode without compound vertices. 7 | /// 8 | Simple, 9 | 10 | /// 11 | /// Compound vertices, compound graph. 12 | /// 13 | Compound 14 | } 15 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/LayoutParametersBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace GraphSharp.Algorithms.Layout 4 | { 5 | public abstract class LayoutParametersBase : ILayoutParameters 6 | { 7 | #region ICloneable Members 8 | 9 | public object Clone() 10 | { 11 | return this.MemberwiseClone(); 12 | } 13 | 14 | #endregion 15 | 16 | #region INotifyPropertyChanged Members 17 | 18 | public event PropertyChangedEventHandler PropertyChanged; 19 | 20 | protected void NotifyPropertyChanged(string propertyName) 21 | { 22 | //delegating to the event... 23 | PropertyChangedEventHandler handler = PropertyChanged; 24 | if (handler != null) 25 | handler(this, new PropertyChangedEventArgs(propertyName)); 26 | } 27 | #endregion 28 | } 29 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/LayoutState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.Layout 6 | { 7 | public class LayoutState 8 | { 9 | /// 10 | /// Gets the position of every vertex in this state of the layout process. 11 | /// 12 | public IDictionary Positions { get; protected set; } 13 | 14 | public IDictionary OverlapRemovedPositions { get; set; } 15 | 16 | public IDictionary RouteInfos { get; set; } 17 | 18 | /// 19 | /// Gets how much time did it take to compute the position of the vertices (till the end of this iteration). 20 | /// 21 | public TimeSpan ComputationTime { get; protected set; } 22 | 23 | /// 24 | /// Gets the index of the iteration. 25 | /// 26 | public int Iteration { get; protected set; } 27 | 28 | /// 29 | /// Get the status message of this layout state. 30 | /// 31 | public string Message { get; protected set; } 32 | 33 | public LayoutState( 34 | IDictionary positions, 35 | IDictionary overlapRemovedPositions, 36 | IDictionary routeInfos, 37 | TimeSpan computationTime, 38 | int iteration, 39 | string message ) 40 | { 41 | Positions = positions; 42 | OverlapRemovedPositions = overlapRemovedPositions ?? positions; 43 | RouteInfos = routeInfos ?? new Dictionary( 0 ); 44 | 45 | ComputationTime = computationTime; 46 | Iteration = iteration; 47 | Message = message; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Circular/CircularLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout.Simple.Circular 2 | { 3 | public class CircularLayoutParameters : LayoutParametersBase 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/BoundedFRLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GraphSharp.Algorithms.Layout.Simple.FDP 4 | { 5 | /// 6 | /// Parameters of the Fruchterman-Reingold Algorithm (FDP), bounded version. 7 | /// 8 | public class BoundedFRLayoutParameters : FRLayoutParametersBase 9 | { 10 | #region Properties, Parameters 11 | //some of the parameters declared with 'internal' modifier to 'speed up' 12 | 13 | private double _width = 100; 14 | private double _height = 100; 15 | private double _k; 16 | 17 | /// 18 | /// Width of the bounding box. 19 | /// 20 | public double Width 21 | { 22 | get { return _width; } 23 | set 24 | { 25 | _width = value; 26 | UpdateParameters(); 27 | NotifyPropertyChanged("Width"); 28 | } 29 | } 30 | 31 | /// 32 | /// Height of the bounding box. 33 | /// 34 | public double Height 35 | { 36 | get { return _height; } 37 | set 38 | { 39 | _height = value; 40 | UpdateParameters(); 41 | NotifyPropertyChanged("Height"); 42 | } 43 | } 44 | 45 | /// 46 | /// Constant. IdealEdgeLength = sqrt(height * width / vertexCount) 47 | /// 48 | public override double K 49 | { 50 | get { return _k; } 51 | } 52 | 53 | /// 54 | /// Gets the initial temperature of the mass. 55 | /// 56 | public override double InitialTemperature 57 | { 58 | get { return Math.Min(Width, Height) / 10; } 59 | } 60 | 61 | protected override void UpdateParameters() 62 | { 63 | _k = Math.Sqrt(_width * Height / VertexCount); 64 | NotifyPropertyChanged("K"); 65 | base.UpdateParameters(); 66 | } 67 | 68 | #endregion 69 | } 70 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/FRCoolingFunction.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout.Simple.FDP 2 | { 3 | public enum FRCoolingFunction 4 | { 5 | Linear, 6 | Exponential 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/FRLayoutAlgorithm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/Layout/Simple/FDP/FRLayoutAlgorithm.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/FreeFRLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GraphSharp.Algorithms.Layout.Simple.FDP 4 | { 5 | public class FreeFRLayoutParameters : FRLayoutParametersBase 6 | { 7 | private double _idealEdgeLength = 10; 8 | 9 | public override double K 10 | { 11 | get { return _idealEdgeLength; } 12 | } 13 | 14 | public override double InitialTemperature 15 | { 16 | get { return Math.Sqrt(Math.Pow(_idealEdgeLength, 2) * VertexCount); } 17 | } 18 | 19 | /// 20 | /// Constant. Represents the ideal length of the edges. 21 | /// 22 | public double IdealEdgeLength 23 | { 24 | get { return _idealEdgeLength; } 25 | set 26 | { 27 | _idealEdgeLength = value; 28 | UpdateParameters(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/ISOMLayoutAlgorithm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/Layout/Simple/FDP/ISOMLayoutAlgorithm.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/KKLayoutAlgorithm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/Layout/Simple/FDP/KKLayoutAlgorithm.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/LinLogLayoutAlgorithm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/Layout/Simple/FDP/LinLogLayoutAlgorithm.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/FDP/LinLogLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.Layout.Simple.FDP 2 | { 3 | public class LinLogLayoutParameters : LayoutParametersBase 4 | { 5 | internal double attractionExponent = 1.0; 6 | 7 | public double AttractionExponent 8 | { 9 | get { return attractionExponent; } 10 | set 11 | { 12 | attractionExponent = value; 13 | NotifyPropertyChanged("AttractionExponent"); 14 | } 15 | } 16 | 17 | internal double repulsiveExponent; 18 | 19 | public double RepulsiveExponent 20 | { 21 | get { return repulsiveExponent; } 22 | set 23 | { 24 | repulsiveExponent = value; 25 | NotifyPropertyChanged("RepulsiveExponent"); 26 | } 27 | } 28 | 29 | internal double gravitationMultiplier = 0.1; 30 | 31 | public double GravitationMultiplier 32 | { 33 | get { return gravitationMultiplier; } 34 | set 35 | { 36 | gravitationMultiplier = value; 37 | NotifyPropertyChanged("GravitationMultiplier"); 38 | } 39 | } 40 | 41 | internal int iterationCount = 100; 42 | 43 | public int IterationCount 44 | { 45 | get { return iterationCount; } 46 | set 47 | { 48 | iterationCount = value; 49 | NotifyPropertyChanged("IterationCount"); 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Hierarchical/EfficientSugiyamaAlgorithm.DoPreparing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using QuickGraph; 4 | using QuickGraph.Algorithms.Search; 5 | 6 | namespace GraphSharp.Algorithms.Layout.Simple.Hierarchical 7 | { 8 | public partial class EfficientSugiyamaLayoutAlgorithm 9 | where TVertex : class 10 | where TEdge : IEdge 11 | where TGraph : IVertexAndEdgeListGraph 12 | { 13 | private void DoPreparing() 14 | { 15 | RemoveCycles(); 16 | RemoveLoops(); 17 | RemoveIsolatedVertices(); //it must run after the two method above 18 | } 19 | 20 | private void RemoveIsolatedVertices() 21 | { 22 | _isolatedVertices = _graph.Vertices.Where(v => _graph.Degree(v) == 0).ToList(); 23 | foreach (var isolatedVertex in _isolatedVertices) 24 | _graph.RemoveVertex(isolatedVertex); 25 | } 26 | 27 | /// 28 | /// Removes the edges which source and target is the same vertex. 29 | /// 30 | private void RemoveLoops() 31 | { 32 | _graph.RemoveEdgeIf(edge => edge.Source == edge.Target); 33 | } 34 | 35 | /// 36 | /// Removes the cycles from the original graph with simply reverting 37 | /// some edges. 38 | /// 39 | private void RemoveCycles() 40 | { 41 | //find the cycle edges with dfs 42 | var cycleEdges = new List(); 43 | var dfsAlgo = new DepthFirstSearchAlgorithm(_graph); 44 | dfsAlgo.BackEdge += cycleEdges.Add; 45 | dfsAlgo.Compute(); 46 | 47 | //and revert them 48 | foreach (var edge in cycleEdges) 49 | { 50 | _graph.RemoveEdge(edge); 51 | _graph.AddEdge(new SugiEdge(edge.OriginalEdge, edge.Target, edge.Source)); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Hierarchical/SugiyamaEdgeRoutings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Algorithms.Layout.Simple.Hierarchical 7 | { 8 | public enum SugiyamaEdgeRoutings 9 | { 10 | Traditional, 11 | Orthogonal 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Hierarchical/SugiyamaLayoutAlgorithm.Enums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Layout.Simple.Hierarchical 5 | { 6 | public partial class SugiyamaLayoutAlgorithm 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | [Flags] 12 | protected enum BaryCenter 13 | { 14 | Up = 1, 15 | Down = 2, 16 | Sub = 4 17 | } 18 | 19 | [Flags] 20 | protected enum CrossCount 21 | { 22 | Up = 1, 23 | Down = 2 24 | } 25 | 26 | protected enum SweepingDirection 27 | { 28 | Up = 1, 29 | Down = 2 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Hierarchical/SugiyamaLayoutAlgorithm.SugiEdge.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Layout.Simple.Hierarchical 5 | { 6 | public partial class SugiyamaLayoutAlgorithm 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | private class SugiEdge : Edge, ITypedEdge 12 | { 13 | public bool IsLongEdge 14 | { 15 | get { return DummyVertices != null; } 16 | set 17 | { 18 | if ( IsLongEdge != value ) 19 | { 20 | DummyVertices = value ? new List() : null; 21 | } 22 | } 23 | } 24 | 25 | public IList DummyVertices { get; private set; } 26 | public TEdge Original { get; private set; } 27 | public EdgeTypes Type { get; private set; } 28 | 29 | public bool IsReverted 30 | { 31 | get 32 | { 33 | return !Original.Equals(default(TEdge)) && Original.Source == Target.Original && Original.Target == Source.Original; 34 | } 35 | } 36 | 37 | public SugiEdge( TEdge original, SugiVertex source, SugiVertex target, EdgeTypes type ) 38 | : base( source, target) 39 | { 40 | Original = original; 41 | Type = type; 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return string.Format("{0}: {1}-->{2}", Type, this.Source, this.Target); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Hierarchical/SugiyamaLayoutAlgorithm.VertexLayerCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp.Algorithms.Layout.Simple.Hierarchical 5 | { 6 | public partial class SugiyamaLayoutAlgorithm 7 | where TVertex : class 8 | where TEdge : IEdge 9 | where TGraph : IVertexAndEdgeListGraph 10 | { 11 | /// 12 | /// Collection of the layers of the vertices. 13 | /// 14 | private class VertexLayerCollection : List 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Tree/BalloonTreeLayoutParameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Algorithms.Layout.Simple.Tree 7 | { 8 | public class BalloonTreeLayoutParameters : LayoutParametersBase 9 | { 10 | internal int minRadius = 2; 11 | internal float border = 20.0f; 12 | 13 | public int MinRadius 14 | { 15 | get { return minRadius; } 16 | set 17 | { 18 | if ( value != minRadius ) 19 | { 20 | minRadius = value; 21 | NotifyPropertyChanged( "MinRadius" ); 22 | } 23 | } 24 | } 25 | 26 | 27 | public float Border 28 | { 29 | get { return border; } 30 | set 31 | { 32 | if ( value != border ) 33 | { 34 | border = value; 35 | NotifyPropertyChanged( "Border" ); 36 | } 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Tree/SimpleTreeLayoutAlgorithm.Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using QuickGraph; 6 | 7 | namespace GraphSharp.Algorithms.Layout.Simple.Tree 8 | { 9 | public partial class SimpleTreeLayoutAlgorithm : DefaultParameterizedLayoutAlgorithmBase 10 | where TVertex : class 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | class Layer 15 | { 16 | public double Size; 17 | public double NextPosition; 18 | public readonly IList Vertices = new List(); 19 | public double LastTranslate; 20 | 21 | public Layer() 22 | { 23 | LastTranslate = 0; 24 | } 25 | 26 | /* Width and Height Optimization */ 27 | 28 | } 29 | 30 | class VertexData 31 | { 32 | public TVertex parent; 33 | public double translate; 34 | public double position; 35 | 36 | /* Width and Height Optimization */ 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Tree/SimpleTreeLayoutAlgorithm.WidthAndHeightOpt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using QuickGraph; 6 | 7 | namespace GraphSharp.Algorithms.Layout.Simple.Tree 8 | { 9 | public partial class SimpleTreeLayoutAlgorithm : DefaultParameterizedLayoutAlgorithmBase 10 | where TVertex : class 11 | where TEdge : IEdge 12 | where TGraph : IBidirectionalGraph 13 | { 14 | /*private void DoWidthAndHeightOptimization() 15 | { 16 | CreateVertexWHOptInfos(); 17 | CreateLayerWHOptInfos(); 18 | 19 | if (_actualWidthPerHeight <= Parameters.WidthPerHeight) 20 | return; 21 | 22 | bool optimized = false; 23 | do 24 | { 25 | optimized = DoWHOptimizationStep(); 26 | } while (optimized); 27 | RewriteLayerIndexes(); 28 | } 29 | 30 | private void CreateVertexWHOptInfos() 31 | { 32 | 33 | } 34 | private void CreateLayerWHOptInfos() 35 | { 36 | 37 | } 38 | private bool DoWHOptimizationStep() 39 | { 40 | 41 | } 42 | private void RewriteLayerIndexes() 43 | { 44 | 45 | }*/ 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/Layout/Simple/Tree/SpanningTreeGeneration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Algorithms.Layout.Simple.Tree 7 | { 8 | public enum SpanningTreeGeneration 9 | { 10 | BFS, 11 | DFS 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/FSAAlgorithm.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/OverlapRemoval/FSAAlgorithm.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/IOverlapRemovalAlgorithm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Algorithms.OverlapRemoval 5 | { 6 | public interface IOverlapRemovalAlgorithm : IAlgorithm 7 | { 8 | IDictionary Rectangles { get; } 9 | 10 | IOverlapRemovalParameters GetParameters(); 11 | } 12 | 13 | public interface IOverlapRemovalAlgorithm : IOverlapRemovalAlgorithm 14 | where TParam : IOverlapRemovalParameters 15 | { 16 | TParam Parameters { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/IOverlapRemovalAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace GraphSharp.Algorithms.OverlapRemoval 4 | { 5 | public interface IOverlapRemovalAlgorithmFactory 6 | where TVertex : class 7 | { 8 | /// 9 | /// List of the available algorithms. 10 | /// 11 | IEnumerable AlgorithmTypes { get; } 12 | 13 | IOverlapRemovalAlgorithm CreateAlgorithm( string newAlgorithmType, IOverlapRemovalContext context, IOverlapRemovalParameters parameters ); 14 | 15 | IOverlapRemovalParameters CreateParameters( string algorithmType, IOverlapRemovalParameters oldParameters ); 16 | 17 | bool IsValidAlgorithm( string algorithmType ); 18 | 19 | string GetAlgorithmType( IOverlapRemovalAlgorithm algorithm ); 20 | } 21 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/IOverlapRemovalContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace GraphSharp.Algorithms.OverlapRemoval 5 | { 6 | public interface IOverlapRemovalContext 7 | { 8 | IDictionary Rectangles { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/IOverlapRemovalParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.OverlapRemoval 2 | { 3 | public interface IOverlapRemovalParameters : IAlgorithmParameters 4 | { 5 | float VerticalGap { get; } 6 | float HorizontalGap { get; } 7 | } 8 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/OneWayFSAParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.OverlapRemoval 2 | { 3 | public enum OneWayFSAWayEnum { 4 | Horizontal, 5 | Vertical 6 | } 7 | 8 | public class OneWayFSAParameters : OverlapRemovalParameters 9 | { 10 | private OneWayFSAWayEnum way; 11 | public OneWayFSAWayEnum Way 12 | { 13 | get { return way; } 14 | set 15 | { 16 | if ( way != value ) 17 | { 18 | way = value; 19 | NotifyChanged( "Way" ); 20 | } 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/OverlapRemovalAlgorithmBase.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/OverlapRemoval/OverlapRemovalAlgorithmBase.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/OverlapRemovalContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.Contracts; 3 | using System.Windows; 4 | 5 | namespace GraphSharp.Algorithms.OverlapRemoval 6 | { 7 | public class OverlapRemovalContext : IOverlapRemovalContext 8 | { 9 | public IDictionary Rectangles { get; private set; } 10 | 11 | public OverlapRemovalContext( IDictionary rectangles ) 12 | { 13 | Rectangles = rectangles; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/OverlapRemovalHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace GraphSharp.Algorithms.OverlapRemoval 4 | { 5 | public static class OverlapRemovalHelper 6 | { 7 | public static Point GetCenter( this Rect r ) 8 | { 9 | return new Point( r.Left + r.Width / 2, r.Top + r.Height / 2 ); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/OverlapRemovalParameters.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp.Algorithms.OverlapRemoval 2 | { 3 | public class OverlapRemovalParameters : IOverlapRemovalParameters 4 | { 5 | private float verticalGap = 10; 6 | private float horizontalGap = 10; 7 | 8 | public float VerticalGap 9 | { 10 | get { return verticalGap; } 11 | set 12 | { 13 | if ( verticalGap != value ) 14 | { 15 | verticalGap = value; 16 | NotifyChanged( "VerticalGap" ); 17 | } 18 | } 19 | } 20 | 21 | public float HorizontalGap 22 | { 23 | get { return horizontalGap; } 24 | set 25 | { 26 | if ( horizontalGap != value ) 27 | { 28 | horizontalGap = value; 29 | NotifyChanged( "HorizontalGap" ); 30 | } 31 | } 32 | } 33 | 34 | public object Clone() 35 | { 36 | return MemberwiseClone(); 37 | } 38 | 39 | protected void NotifyChanged( string propertyName ) 40 | { 41 | System.ComponentModel.PropertyChangedEventHandler handler = PropertyChanged; 42 | if (handler != null) 43 | handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); 44 | } 45 | 46 | public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 47 | } 48 | } -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/RectangleWrapper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/Algorithms/OverlapRemoval/RectangleWrapper.cs -------------------------------------------------------------------------------- /Source/Graph#/Algorithms/OverlapRemoval/StandardOverlapRemovalAlgorithmFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace GraphSharp.Algorithms.OverlapRemoval 5 | { 6 | public class StandardOverlapRemovalAlgorithmFactory : IOverlapRemovalAlgorithmFactory 7 | where TVertex : class 8 | { 9 | protected static readonly string[] algorithmTypes = new string[] { "FSA", "OneWayFSA" }; 10 | public IEnumerable AlgorithmTypes 11 | { 12 | get { return algorithmTypes; } 13 | } 14 | 15 | public IOverlapRemovalAlgorithm CreateAlgorithm( string newAlgorithmType, IOverlapRemovalContext context, IOverlapRemovalParameters parameters ) 16 | { 17 | if ( context == null || context.Rectangles == null ) 18 | return null; 19 | 20 | switch ( newAlgorithmType ) 21 | { 22 | case "FSA": 23 | return new FSAAlgorithm( context.Rectangles, parameters ); 24 | case "OneWayFSA": 25 | return new OneWayFSAAlgorithm( context.Rectangles, parameters as OneWayFSAParameters ); 26 | default: 27 | return null; 28 | } 29 | } 30 | 31 | public IOverlapRemovalParameters CreateParameters( string algorithmType, IOverlapRemovalParameters oldParameters ) 32 | { 33 | switch ( algorithmType ) 34 | { 35 | case "FSA": 36 | return oldParameters as OverlapRemovalParameters == null 37 | ? new OverlapRemovalParameters() 38 | : (IOverlapRemovalParameters)(oldParameters as OverlapRemovalParameters).Clone(); 39 | case "OneWayFSA": 40 | return ( oldParameters as OneWayFSAParameters ) == null 41 | ? new OneWayFSAParameters() 42 | : (IOverlapRemovalParameters)oldParameters.Clone(); 43 | default: 44 | return null; 45 | } 46 | } 47 | 48 | public string GetAlgorithmType( IOverlapRemovalAlgorithm algorithm ) 49 | { 50 | if ( algorithm is FSAAlgorithm ) 51 | return "FSA"; 52 | else if ( algorithm is OneWayFSAAlgorithm ) 53 | return "OneWayFSA"; 54 | else 55 | return string.Empty; 56 | } 57 | 58 | public bool IsValidAlgorithm( string algorithmType ) 59 | { 60 | return AlgorithmTypes.Contains( algorithmType ); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Source/Graph#/Contracts/IContextualLayoutAlgorithmFactoryContract.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.Contracts; 2 | using System.Linq; 3 | using QuickGraph; 4 | using GraphSharp.Algorithms.Layout; 5 | using GraphSharp.Algorithms.Layout.Contextual; 6 | 7 | namespace GraphSharp.Contracts 8 | { 9 | [ContractClassFor( typeof( IContextualLayoutAlgorithmFactory<,,> ) )] 10 | public class IContextualLayoutAlgorithmFactoryContract : ILayoutAlgorithmFactoryContract, IContextualLayoutAlgorithmFactory 11 | where TVertex : class 12 | where TEdge : IEdge 13 | where TGraph : class, IBidirectionalGraph 14 | { 15 | 16 | #region ILayoutAlgorithmFactory Members 17 | 18 | ILayoutAlgorithm ILayoutAlgorithmFactory.CreateAlgorithm( string newAlgorithmType, ILayoutContext context, ILayoutParameters parameters ) 19 | { 20 | Contract.Requires( newAlgorithmType != null ); 21 | Contract.Requires( context as ContextualLayoutContext != null ); 22 | 23 | var laf = (ILayoutAlgorithmFactory)this; 24 | Contract.Requires( laf.AlgorithmTypes.Contains( newAlgorithmType ) ); 25 | 26 | return default( ILayoutAlgorithm ); 27 | } 28 | 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Graph#/Contracts/ILayoutContextContract.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.Contracts; 3 | using GraphSharp.Algorithms.Layout; 4 | using QuickGraph; 5 | using System.Windows; 6 | 7 | namespace GraphSharp.Contracts 8 | { 9 | [ContractClassFor( typeof( ILayoutContext<,,> ) )] 10 | public class ILayoutContextContract : ILayoutContext 11 | where TEdge : IEdge 12 | where TGraph : class, IBidirectionalGraph 13 | { 14 | [ContractInvariantMethod] 15 | protected void Invariants() 16 | { 17 | var lc = (ILayoutContext)this; 18 | Contract.Invariant( lc.Positions != null ); 19 | Contract.Invariant( lc.Graph != null ); 20 | Contract.Invariant( lc.Sizes != null ); 21 | } 22 | 23 | #region ILayoutContext Members 24 | 25 | IDictionary ILayoutContext.Positions 26 | { 27 | get { return default( IDictionary ); } 28 | } 29 | 30 | IDictionary ILayoutContext.Sizes 31 | { 32 | get { return default( IDictionary ); } 33 | } 34 | 35 | TGraph ILayoutContext.Graph 36 | { 37 | get { return default( TGraph ); } 38 | } 39 | 40 | LayoutMode ILayoutContext.Mode 41 | { 42 | get { return default( LayoutMode ); } 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Graph#/GraphHelper.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/GraphHelper.cs -------------------------------------------------------------------------------- /Source/Graph#/GraphSharp.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Source/Graph#/GraphSharp.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/graphsharp/dc60ca80de5f600acafdf254aba09cdb67f06f1d/Source/Graph#/GraphSharp.snk -------------------------------------------------------------------------------- /Source/Graph#/ICompoundGraph.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using System.Diagnostics.Contracts; 4 | 5 | namespace GraphSharp 6 | { 7 | public interface ICompoundGraph : IBidirectionalGraph 8 | where TEdge : IEdge 9 | { 10 | bool AddChildVertex( TVertex parent, TVertex child ); 11 | int AddChildVertexRange( TVertex parent, IEnumerable children ); 12 | TVertex GetParent( TVertex vertex ); 13 | bool IsChildVertex( TVertex vertex ); 14 | IEnumerable GetChildrenVertices( TVertex vertex ); 15 | int GetChildrenCount( TVertex vertex ); 16 | bool IsCompoundVertex( TVertex vertex ); 17 | 18 | IEnumerable CompoundVertices { get; } 19 | IEnumerable SimpleVertices { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Graph#/IHierarchicalBidirectionalGraph.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | 4 | namespace GraphSharp 5 | { 6 | public interface IHierarchicalBidirectionalGraph : IBidirectionalGraph 7 | where TEdge : ITypedEdge 8 | { 9 | IEnumerable HierarchicalEdgesFor(TVertex v); 10 | int HierarchicalEdgeCountFor(TVertex v); 11 | IEnumerable HierarchicalEdges { get; } 12 | int HierarchicalEdgeCount { get; } 13 | 14 | IEnumerable InHierarchicalEdges(TVertex v); 15 | int InHierarchicalEdgeCount(TVertex v); 16 | 17 | IEnumerable OutHierarchicalEdges(TVertex v); 18 | int OutHierarchicalEdgeCount(TVertex v); 19 | 20 | IEnumerable GeneralEdgesFor(TVertex v); 21 | int GeneralEdgeCountFor(TVertex v); 22 | IEnumerable GeneralEdges { get; } 23 | int GeneralEdgeCount { get; } 24 | 25 | IEnumerable InGeneralEdges(TVertex v); 26 | int InGeneralEdgeCount(TVertex v); 27 | 28 | IEnumerable OutGeneralEdges(TVertex v); 29 | int OutGeneralEdgeCount(TVertex v); 30 | } 31 | } -------------------------------------------------------------------------------- /Source/Graph#/ILengthEdge.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp 4 | { 5 | public interface ILengthEdge : IEdge 6 | { 7 | double Length { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Source/Graph#/IMutableCompoundGraph.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp 4 | { 5 | public interface IMutableCompoundGraph 6 | : ICompoundGraph, 7 | IMutableBidirectionalGraph 8 | where TEdge : IEdge 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Graph#/ISoftMutableGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QuickGraph; 4 | 5 | namespace GraphSharp 6 | { 7 | /// 8 | /// Soft mutation means: We can hide the vertices or the edges. 9 | /// 10 | /// 11 | /// 12 | public interface ISoftMutableGraph : IBidirectionalGraph 13 | where TEdge : IEdge 14 | { 15 | bool HideVertex( TVertex v ); 16 | bool HideVertex( TVertex v, string tag ); 17 | void HideVertices( IEnumerable vertices ); 18 | void HideVertices( IEnumerable vertices, string tag ); 19 | void HideVerticesIf( Func predicate, string tag ); 20 | bool IsHiddenVertex( TVertex v ); 21 | bool UnhideVertex( TVertex v ); 22 | void UnhideVertexAndEdges( TVertex v ); 23 | IEnumerable HiddenVertices { get; } 24 | int HiddenVertexCount { get; } 25 | 26 | bool HideEdge( TEdge e ); 27 | bool HideEdge( TEdge e, string tag ); 28 | void HideEdges( IEnumerable edges ); 29 | void HideEdges( IEnumerable edges, string tag ); 30 | void HideEdgesIf( Func predicate, string tag ); 31 | bool IsHiddenEdge( TEdge e ); 32 | bool UnhideEdge( TEdge e ); 33 | void UnhideEdges( IEnumerable edges ); 34 | void UnhideEdgesIf( Func predicate ); 35 | IEnumerable HiddenEdgesOf( TVertex v ); 36 | int HiddenEdgeCountOf( TVertex v ); 37 | IEnumerable HiddenEdges { get; } 38 | int HiddenEdgeCount { get; } 39 | 40 | bool Unhide( string tag ); 41 | bool UnhideAll( ); 42 | } 43 | } -------------------------------------------------------------------------------- /Source/Graph#/ITypedEdge.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp 4 | { 5 | public enum EdgeTypes 6 | { 7 | General, 8 | Hierarchical 9 | } 10 | 11 | public interface ITypedEdge : IEdge 12 | { 13 | EdgeTypes Type { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /Source/Graph#/IWeightedEdge.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | 3 | namespace GraphSharp 4 | { 5 | public interface IWeightedEdge : IEdge 6 | { 7 | double Weight { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Source/Graph#/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle( "GraphSharp" )] 9 | [assembly: AssemblyDescription( "" )] 10 | [assembly: AssemblyConfiguration( "" )] 11 | [assembly: AssemblyCompany( "" )] 12 | [assembly: AssemblyProduct( "GraphSharp" )] 13 | [assembly: AssemblyCopyright( "Copyright © 2020" )] 14 | [assembly: AssemblyTrademark( "" )] 15 | [assembly: AssemblyCulture( "" )] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible( false )] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid( "c2f5a67f-bbc1-42cd-b204-3163e65b0a4e" )] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion( "1.1.1.0" )] 35 | [assembly: AssemblyFileVersion( "1.1.1.0" )] 36 | -------------------------------------------------------------------------------- /Source/Graph#/WrappedVertex.cs: -------------------------------------------------------------------------------- 1 | namespace GraphSharp 2 | { 3 | public class WrappedVertex 4 | { 5 | private readonly TVertex _originalVertex; 6 | public TVertex Original 7 | { 8 | get { return _originalVertex; } 9 | } 10 | 11 | public WrappedVertex(TVertex original) 12 | { 13 | _originalVertex = original; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Source/Graph#/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace GraphSharp.Optimization 9 | { 10 | /// 11 | /// Interaction logic for App.xaml 12 | /// 13 | public partial class App : Application 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/GeneticAlgorithm/GeneticAlgorithmParameters.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.Contracts; 2 | 3 | namespace GraphSharp.Optimization.GeneticAlgorithm 4 | { 5 | public class GeneticAlgorithmParameters 6 | { 7 | [ContractInvariantMethod] 8 | public void Invariants() 9 | { 10 | Contract.Invariant(Generations > 0); 11 | Contract.Invariant(PopulationSize > 0); 12 | Contract.Invariant(0 <= MutationRate && MutationRate <= 1.0); 13 | Contract.Invariant(0 <= CrossoverRate && CrossoverRate <= 1.0); 14 | Contract.Invariant(0 <= ElitismRate && ElitismRate <= 1.0); 15 | } 16 | 17 | public int Generations { get; set; } 18 | public int PopulationSize { get; set; } 19 | public double MutationRate { get; set; } 20 | public double CrossoverRate { get; set; } 21 | public double ElitismRate { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/GeneticAlgorithm/IMutation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GraphSharp.Optimization.GeneticAlgorithm 7 | { 8 | public interface IMutation 9 | where TGene : class 10 | { 11 | ICollection Mutate(ICollection genes); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("GraphSharp.Optimization")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("GraphSharp.Optimization")] 15 | [assembly: AssemblyCopyright("Copyright © 2009")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.3074 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GraphSharp.Optimization.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Source/GraphSharp.Optimization/Window1.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 |