public StandardPathFinder( IGraphDescriptor graphDescriptor, IPathFinderAuxiliaries pathFinderAuxiliaries) : base(graphDescriptor) { _pathFinderAuxiliaries = pathFinderAuxiliaries; }
public virtual string ToSvg(IGraphDescriptor graphDescriptor, IUndirectedGraph<IContent, IUndirectedEdge<IContent>> graph, Action<GraphvizAlgorithm<IContent, IUndirectedEdge<IContent>>> initialization) { //var stringBuilder = new StringBuilder(); //using (var xmlWriter = XmlWriter.Create(stringBuilder)) //{ // // This may also need attributes on models, see: http://quickgraph.codeplex.com/wikipage?title=GraphML%20Serialization&referringTitle=Documentation // graph.SerializeToGraphML<TNode, IUndirectedEdge<TNode>, IUndirectedGraph<TNode, IUndirectedEdge<TNode>>>( // xmlWriter, // node => node.Label, // edge => edge.Source.ContentItem.Id.ToString() + edge.Target.ContentItem.Id.ToString()); //} //var graphML = stringBuilder.ToString(); // Sadly graph.GetHashCode() gives different results on different requests, therefore only the dot hash // is reliable. Fortunately it's quite fast. var dotData = graph.ToGraphviz(algorithm => { initialization(algorithm); }); var filePath = "_AssociativyModules/Frontends/GraphImages/" + graphDescriptor.Name + "/" + dotData.GetHashCode() + ".svg"; var cacheKey = "Associativy.Frontends.Graphviz.GraphImages." + filePath; return _cacheService.GetMonitored(graphDescriptor, cacheKey, () => { using (var lockFile = _lockManager.TryAcquireLock(cacheKey)) { return RetrieveImage(dotData, filePath); } }); }
public NotionGraphBuilder( IContentManager contentManager, IGraphDescriptor graphDescriptor) { _contentManager = contentManager; _graphDescriptor = graphDescriptor; _connectionManager = graphDescriptor.Services.ConnectionManager; }
public ExternalGraphStatisticsService( IGraphDescriptor graphDescriptor, ICacheService cacheService, IRepository<GraphStatisticsRecord> repository) : base(graphDescriptor) { _cacheService = cacheService; _repository = repository; }
public MemoryConnectionManager( IGraphDescriptor graphDescriptor, ICacheService cacheService, IGraphEventHandler graphEventHandler) : base(graphDescriptor) { _cacheService = cacheService; _graphEventHandler = graphEventHandler; }
protected Neo4jServiceBase( IGraphDescriptor graphDescriptor, Uri rootUri, INeo4jGraphClientPool graphClientPool) : base(graphDescriptor) { _rootUri = rootUri; _graphClientPool = graphClientPool; Logger = NullLogger.Instance; }
public Neo4jPathFinder( IGraphDescriptor graphDescriptor, Uri rootUri, INeo4jGraphClientPool graphClientPool, IPathFinderAuxiliaries pathFinderAuxiliaries, IGraphEventMonitor graphEventMonitor) : base(graphDescriptor, rootUri, graphClientPool) { _graphEventMonitor = graphEventMonitor; _pathFinderAuxiliaries = pathFinderAuxiliaries; }
public StandardNodeManager( IGraphDescriptor graphDescriptor, IContentManager contentManager, IGraphEditor graphEditor, INodeIndexingService indexingService, INodeManagerEventHander eventHandler) : base(graphDescriptor) { _contentManager = contentManager; _graphEditor = graphEditor; _indexingService = indexingService; _eventHandler = eventHandler; }
public StandardMind( IGraphDescriptor graphDescriptor, IQueryableGraphFactory queryableFactory, IGraphEditor graphEditor, IMindEventHandler eventHandler, IGraphCacheService cacheService) : base(graphDescriptor) { _queryableFactory = queryableFactory; _graphEditor = graphEditor; _eventHandler = eventHandler; _cacheService = cacheService; }
public override void Changed(IGraphDescriptor graphDescriptor) { ConcurrentDictionary<string, byte> dictionary; if (GetKeys().TryGetValue(graphDescriptor.Name, out dictionary)) { byte dummy; foreach (var cacheKey in dictionary.Keys.ToList()) { _cacheService.Remove(cacheKey); dictionary.TryRemove(cacheKey, out dummy); } } }
public Neo4jConnectionManager( IGraphDescriptor graphDescriptor, Uri rootUri, INeo4jGraphClientPool graphClientPool, Func<IGraphDescriptor, IExternalGraphStatisticsService> statisticsService, INeo4jGraphInfoService infoService, IGraphCacheService cacheService, IGraphEventHandler graphEventHandler) : base(graphDescriptor, rootUri, graphClientPool) { _statisticsService = statisticsService(_graphDescriptor); _infoService = infoService; _cacheService = cacheService; _graphEventHandler = graphEventHandler; Logger = NullLogger.Instance; }
public void MonitorChanged(IGraphDescriptor graphDescriptor, string cacheKey) { var newDicionaryLazy = new Lazy<ConcurrentDictionary<string, byte>>(() => { var dictionary = new ConcurrentDictionary<string, byte>(); dictionary[cacheKey] = 0; return dictionary; }); GetKeys().AddOrUpdate( graphDescriptor.Name, newDicionaryLazy.Value, (key, dictionary) => { dictionary[cacheKey] = 0; return dictionary; }); }
public virtual void ConnectionsDeletedFromNode(IGraphDescriptor graphDescriptor, int nodeId) { Changed(graphDescriptor); }
public static NotionGraphBuilder BuildTestGraph(IContentManager contentManager, IGraphDescriptor graphDescriptor) { var graphBuilder = new NotionGraphBuilder(contentManager, graphDescriptor); graphBuilder.Build(false, false); return graphBuilder; }
public override void Init() { base.Init(); var builder = new ContainerBuilder(); var cacheService = new StubCacheService(); builder.RegisterInstance(new GraphEventMonitor(cacheService)).As<IGraphEventMonitor>(); builder.RegisterInstance(new StubNodeManager()).As<INodeManager>(); builder.RegisterInstance(new StubGraphEditor()).As<IGraphEditor>(); builder.RegisterInstance(cacheService).As<ICacheService>(); builder.RegisterInstance(new StubQueryableGraphFactory()).As<IQueryableGraphFactory>(); builder.RegisterType<GraphCacheService>().As<IGraphCacheService>(); builder.RegisterInstance(new StubCacheService()).As<ICacheService>(); builder.RegisterType<StubGraphManager>().As<IGraphManager>(); builder.RegisterType<StandardMind>().As<IMind>(); builder.RegisterType<MemoryConnectionManager>().As<IConnectionManager>(); builder.RegisterType<PathFinderAuxiliaries>().As<IPathFinderAuxiliaries>(); builder.RegisterType<StandardPathFinder>().As<IPathFinder>(); StubGraphManager.Setup(builder); builder.Update(_container); _graphDescriptor = _container.Resolve<IGraphManager>().FindGraph(null); _contentManager = _container.Resolve<IContentManager>(); }
protected GraphAwareServiceBase(IGraphDescriptor graphDescriptor) { _graphDescriptor = graphDescriptor; }
protected MindEventContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IQueryableGraph<int> idGraph) { GraphDescriptor = graphDescriptor; Settings = settings; IdGraph = idGraph; }
public SearchedGraphBuiltContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IEnumerable<int> nodeIds, IQueryableGraph<int> idGraph) : base(graphDescriptor, settings, idGraph) { NodeIds = nodeIds; }
/// <summary> /// Sorts the nodes of a graph in topological order. /// </summary> /// <typeparam name="TNode">The type of a node.</typeparam> /// <typeparam name="TKey">The type of a node key.</typeparam> /// <param name="nodes">The set of nodes.</param> /// <param name="descriptor">The object describing how to navigate the graph.</param> /// <returns>The topologically sorted nodes.</returns> /// <exception cref="Shields.Graphs.GraphCycleException">This exception is thrown if the graph contains a cycle.</exception> public static IEnumerable <TNode> OrderTopologically <TNode, TKey>( this IEnumerable <TNode> nodes, IGraphDescriptor <TNode, TKey> descriptor) { return(OrderTopologically(nodes, descriptor.Key, descriptor.Next)); }
public static IUndirectedGraph<IContent, IUndirectedEdge<IContent>> ToContentGraph(this IUndirectedGraph<int, IUndirectedEdge<int>> idGraph, IGraphDescriptor graphDescriptor) { return graphDescriptor.Services.NodeManager.MakeContentGraph(idGraph); }
/// <summary> /// Gets the connected components of a graph. For digraphs use <see cref="StronglyConnectedComponents"/>. /// </summary> /// <typeparam name="TNode">The type of a node.</typeparam> /// <typeparam name="TKey">The type of a node key.</typeparam> /// <param name="nodes">The set of nodes.</param> /// <param name="descriptor">The object describing how to navigate the graph.</param> /// <returns>The connected components of the graph.</returns> public static IEnumerable <IEnumerable <TNode> > ConnectedComponents <TNode, TKey>( this IEnumerable <TNode> nodes, IGraphDescriptor <TNode, TKey> descriptor) { return(ConnectedComponents(nodes, descriptor.Key, descriptor.Next)); }
public QueryBuiltContext(IGraphDescriptor graphDescriptor, IContentQuery<ContentItem> query) { GraphDescriptor = graphDescriptor; Query = query; }
public AllAssociationsGraphBuiltContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IQueryableGraph<int> idGraph) : base(graphDescriptor, settings, idGraph) { }
public virtual void NodeRemoved(IGraphDescriptor graphDescriptor, IContent node) { Changed(graphDescriptor); }
/// <summary> /// Performs a depth-first traversal of a graph or digraph. /// </summary> /// <typeparam name="TNode">The type of a node.</typeparam> /// <typeparam name="TKey">The type of a node key.</typeparam> /// <param name="sources">The set of nodes from which to start the traversal.</param> /// <param name="descriptor">The object describing how to navigate the graph.</param> /// <returns>The depth-first traversal of nodes.</returns> public static IEnumerable <TNode> DepthFirstTraversal <TNode, TKey>( this IEnumerable <TNode> sources, IGraphDescriptor <TNode, TKey> descriptor) { return(DepthFirstTraversal(sources, descriptor.Key, descriptor.Next)); }
public virtual void ConnectionDeleted(IGraphDescriptor graphDescriptor, int nodeId1, int nodeId2) { Changed(graphDescriptor); }
public abstract void Changed(IGraphDescriptor graphDescriptor);