コード例 #1
0
 public StandardPathFinder(
     IGraphDescriptor graphDescriptor,
     IPathFinderAuxiliaries pathFinderAuxiliaries)
     : base(graphDescriptor)
 {
     _pathFinderAuxiliaries = pathFinderAuxiliaries;
 }
コード例 #2
0
        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);
                    }
                });
        }
コード例 #3
0
 public NotionGraphBuilder(
     IContentManager contentManager,
     IGraphDescriptor graphDescriptor)
 {
     _contentManager = contentManager;
     _graphDescriptor = graphDescriptor;
     _connectionManager = graphDescriptor.Services.ConnectionManager;
 }
コード例 #4
0
 public ExternalGraphStatisticsService(
     IGraphDescriptor graphDescriptor,
     ICacheService cacheService,
     IRepository<GraphStatisticsRecord> repository)
     : base(graphDescriptor)
 {
     _cacheService = cacheService;
     _repository = repository;
 }
コード例 #5
0
 public MemoryConnectionManager(
     IGraphDescriptor graphDescriptor,
     ICacheService cacheService,
     IGraphEventHandler graphEventHandler)
     : base(graphDescriptor)
 {
     _cacheService = cacheService;
     _graphEventHandler = graphEventHandler;
 }
コード例 #6
0
        protected Neo4jServiceBase(
            IGraphDescriptor graphDescriptor,
            Uri rootUri,
            INeo4jGraphClientPool graphClientPool)
            : base(graphDescriptor)
        {
            _rootUri = rootUri;
            _graphClientPool = graphClientPool;

            Logger = NullLogger.Instance;
        }
コード例 #7
0
 public Neo4jPathFinder(
     IGraphDescriptor graphDescriptor,
     Uri rootUri,
     INeo4jGraphClientPool graphClientPool,
     IPathFinderAuxiliaries pathFinderAuxiliaries,
     IGraphEventMonitor graphEventMonitor)
     : base(graphDescriptor, rootUri, graphClientPool)
 {
     _graphEventMonitor = graphEventMonitor;
     _pathFinderAuxiliaries = pathFinderAuxiliaries;
 }
コード例 #8
0
 public StandardNodeManager(
     IGraphDescriptor graphDescriptor,
     IContentManager contentManager,
     IGraphEditor graphEditor,
     INodeIndexingService indexingService,
     INodeManagerEventHander eventHandler)
     : base(graphDescriptor)
 {
     _contentManager = contentManager;
     _graphEditor = graphEditor;
     _indexingService = indexingService;
     _eventHandler = eventHandler;
 }
コード例 #9
0
 public StandardMind(
     IGraphDescriptor graphDescriptor,
     IQueryableGraphFactory queryableFactory,
     IGraphEditor graphEditor,
     IMindEventHandler eventHandler,
     IGraphCacheService cacheService)
     : base(graphDescriptor)
 {
     _queryableFactory = queryableFactory;
     _graphEditor = graphEditor;
     _eventHandler = eventHandler;
     _cacheService = cacheService;
 }
コード例 #10
0
        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);
                }
            }
        }
コード例 #11
0
        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;
        }
コード例 #12
0
        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;
                });
        }
コード例 #13
0
 public virtual void ConnectionsDeletedFromNode(IGraphDescriptor graphDescriptor, int nodeId)
 {
     Changed(graphDescriptor);
 }
コード例 #14
0
 public static NotionGraphBuilder BuildTestGraph(IContentManager contentManager, IGraphDescriptor graphDescriptor)
 {
     var graphBuilder = new NotionGraphBuilder(contentManager, graphDescriptor);
     graphBuilder.Build(false, false);
     return graphBuilder;
 }
コード例 #15
0
ファイル: MindTests.cs プロジェクト: Lombiq/Associativy-Core
        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>();
        }
コード例 #16
0
 protected GraphAwareServiceBase(IGraphDescriptor graphDescriptor)
 {
     _graphDescriptor = graphDescriptor;
 }
コード例 #17
0
 protected MindEventContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IQueryableGraph<int> idGraph)
 {
     GraphDescriptor = graphDescriptor;
     Settings = settings;
     IdGraph = idGraph;
 }
コード例 #18
0
 public SearchedGraphBuiltContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IEnumerable<int> nodeIds, IQueryableGraph<int> idGraph)
     : base(graphDescriptor, settings, idGraph)
 {
     NodeIds = nodeIds;
 }
コード例 #19
0
 /// <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));
 }
コード例 #20
0
 public static IUndirectedGraph<IContent, IUndirectedEdge<IContent>> ToContentGraph(this IUndirectedGraph<int, IUndirectedEdge<int>> idGraph, IGraphDescriptor graphDescriptor)
 {
     return graphDescriptor.Services.NodeManager.MakeContentGraph(idGraph);
 }
コード例 #21
0
 /// <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));
 }
コード例 #22
0
 public QueryBuiltContext(IGraphDescriptor graphDescriptor, IContentQuery<ContentItem> query)
 {
     GraphDescriptor = graphDescriptor;
     Query = query;
 }
コード例 #23
0
 public AllAssociationsGraphBuiltContext(IGraphDescriptor graphDescriptor, IMindSettings settings, IQueryableGraph<int> idGraph)
     : base(graphDescriptor, settings, idGraph)
 {
 }
コード例 #24
0
 public virtual void NodeRemoved(IGraphDescriptor graphDescriptor, IContent node)
 {
     Changed(graphDescriptor);
 }
コード例 #25
0
 /// <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));
 }
コード例 #26
0
 public virtual void ConnectionDeleted(IGraphDescriptor graphDescriptor, int nodeId1, int nodeId2)
 {
     Changed(graphDescriptor);
 }
コード例 #27
0
 public abstract void Changed(IGraphDescriptor graphDescriptor);