Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="similarityValue"></param>
        /// <returns></returns>
        private SimilarityDataEdge GenerateSimilarityDataEdge(INode source, INode target, double similarityValue)
        {
            SimilarityDataEdge newSimDataEdge = new SimilarityDataEdge(similarityValue, source, target);

            // Add an attribute to the edge, containing the similarity value
            newSimDataEdge.Attributes.Add("Similarity Value", new Model.Attributes.AttributeValue(similarityValue.ToString()));

            //TODO:  THIS SHOULD BE REMOVED IF EDGES ARE NOT VISIBLE

            return(newSimDataEdge);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new SimilarityEdgeViewModel or retrieves
        /// an existing one from the cache
        /// </summary>
        /// <param name="sourceNode">The source node</param>
        /// <param name="targetNode">The target node</param>
        /// <param name="similarityValue">The similarity value for the provided source and target node</param>
        /// <returns>a new (or cached) SimilarityEdgeViewModel</returns>
        private void GenerateSimilarityEdgeVM(SimilarityDataEdge similarityEdge)
        {
            List <SimilarityEdgeViewModel> nodeSimilarityEdges;
            SimilarityEdgeViewModel        newEdgeVM = null;

            //TODO:  WE NEED TO CLEAR THE CACHE AT SOME POINT IN TIME

            // Get the cache list of edges for the source node
            if (attributeEdgeCache.TryGetValue(similarityEdge.Source, out nodeSimilarityEdges))
            {
                // Loop over all the edges to try and find if we already have one
                // for the given source and target nodes
                foreach (SimilarityEdgeViewModel currentEdgeVM in nodeSimilarityEdges)
                {
                    if (currentEdgeVM.ParentEdge.Target == similarityEdge.Target)
                    {
                        // The edge was previously cached
                        newEdgeVM = currentEdgeVM;
                        break;
                    }
                }
            }
            else
            {
                // Initialize the edge cache list
                attributeEdgeCache[similarityEdge.Target] = new List <SimilarityEdgeViewModel>();
            }

            // If we found an edge, we should return it
            if (newEdgeVM != null)
            {
                GraphManager.Instance.DefaultGraphComponentsInstance.AddEdgeViewModel(newEdgeVM);
            }

            // If we are here, we need to create a brand new edge
            newEdgeVM = new SimilarityEdgeViewModel(similarityEdge, this.scope);

            GraphManager.Instance.DefaultGraphComponentsInstance.AddEdgeViewModel(newEdgeVM);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns bare-bone graph needed for layouts
        /// </summary>
        /// <param name="graphComponents">GraphComponents</param>
        /// <returns>GraphMapData</returns>
        public static GraphMapData GetGraph(GraphComponents graphComponents)
        {
            GraphMapData graph = new GraphMapData();

            // Nodes
            IEnumerable <INodeShape> uiNodeViewModels = graphComponents.GetNodeViewModels();

            foreach (NodeViewModelBase uiNodeVM in uiNodeViewModels)
            {
                NodeMapData objNode = new TextNodeMapData(uiNodeVM.ParentNode.ID);
                graph.Add(objNode);

                // Properties
                Size dimension = new Size(uiNodeVM.Width, uiNodeVM.Height);
                objNode.Dimension = dimension;
                objNode.Position  = uiNodeVM.Position;
                objNode.IsHidden  = uiNodeVM.IsHidden;
            }

            // Edges
            IEnumerable <IEdgeViewModel> uiEdgeViewModels = graphComponents.GetEdgeViewModels();

            foreach (EdgeViewModelBase uiEdgeVM in uiEdgeViewModels)
            {
                EdgeMapData objEdge = new EdgeMapData(uiEdgeVM.ParentEdge.Source.ID, uiEdgeVM.ParentEdge.Target.ID);
                graph.Add(objEdge);

                // Properties
                objEdge.Type = uiEdgeVM.ParentEdge.Type;
                SimilarityDataEdge uiSDE = uiEdgeVM.ParentEdge as SimilarityDataEdge;
                if (uiSDE != null)
                {
                    objEdge.Weight = uiSDE.Weight;
                }
            }

            return(graph);
        }
Esempio n. 4
0
 /// <summary>
 /// Create a new instance of the Berico.LinkAnalysis.ViewModel.SimilarityEdgeViewModel
 /// class using the provided parent edge
 /// </summary>
 /// <param name="parentEdge">The parent edge for this edge view model</param>
 /// <param name="scope">Identifies the scope of this edge view model</param>
 public SimilarityEdgeViewModel(SimilarityDataEdge parentEdge, string scope) : base(parentEdge, scope)
 {
 }