简体   繁体   English

如何使用Java查找图的中心(顶点,该顶点与其他每个顶点相连,但边指向图的中心)

[英]how to Find the center of graph (vertex, that is connected with every other vertex, but edges are directed to the center of graph) with java

how to Find the center of graph (vertex, that is connected with every other vertex, but edges are directed to the center of graph) with java. 如何使用Java查找图的中心(顶点,该顶点与其他每个顶点相连,但边指向图的中心)。 its very useful application for facebook like site. 它对于像Facebook这样的网站非常有用。

Assume you have a graph with a set V of vertices: 假设您有一个图形,其中有一组顶点V:

V = { v1, v2, v3, ... , vn }

Now consider the extreme case where all vertices are connected to v2 and no other edges exist, ie the set of edges E given as tuples (from, to) is: 现在考虑极端情况,其中所有顶点都连接到v2,并且不存在其他边,即,作为元组(从,到)给出的边E的集合为:

E = ( (v1, v2), (v3, v2), ... , (vn, v2) }

In this extreme case v2 clearly is the center of the graph as defined by you. 在这种极端情况下,v2显然是您定义的图形的中心。

The connectivity matrix A looks like follows: 连接矩阵A如下所示:

A = {
   from
to  v1, v2, v3, ..  vn
v1   0   0   0  ..   0    
v2   1   0   1  ..   1
v3   0   0   0  ..   0    
   :               :
vn   0   0   0  ..   0 }

Here v2 is clearly identified as the center of the graph by having a one in every position (excepting pos v2, ie itself) of its row of connectivity matrix A. 在这里v2通过在其连通性矩阵A的行的每个位置(pos v2,即它本身除外)的每个位置都具有一个清楚地标识为图的中心。

This would identify the center of graph even, when there are other edges in E. Note that there could be more than one center ... 即使在E中还有其他边时,也可以标识图的中心。请注意,可能有多个中心...

A less strictly defined center of the graph could be found as the vertice with the most one entries in its row in the connectivity matrix. 在连接矩阵中,图中定义不那么严格的中心可以作为在其行中具有最多条目的顶点。

You can avoid constructing the matrix A, when you have the set E and just count for each vertice how many times it appears in the to position of an edge tuple. 当您拥有集合E并仅计算每个顶点在边缘元组的to位置出现的次数时,可以避免构造矩阵A。 The vertices with the maximum count are the losely defined centers of the graph, or the vertices with a count of n - 1 are your strictly defined centers. 具有最大计数的顶点是图形的丢失定义的中心,或者具有n-1的计数的顶点是您严格定义的中心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java,在有向图中连接边,以便图可遍历 - Java, connected edges in a directed graph so that the graph is traversable 如何在图中找到特定顶点的度数? - How to find the degree of a particular vertex in graph? 如何在来自特定顶点的有向图中执行 BFS 或 DFS,某些顶点的出度为 0? - How to do a BFS or DFS in directed graph from particular vertex with some vertex having outdegree 0? java使用JUNG在有向图中查找连通分量 - java find connected components in Directed Graph using JUNG 生成有向图而无需在Java中返回边 - Generate directed graph without returning edges in java 如何在Titan Graph数据库中使用Java API在新顶点和现有顶点之间创建边 - how to create edge between new vertex and existing vertex using Java API in Titan Graph database 如何将字符串“转换”为顶点以在 Java 中创建图形? - How can I 'convert' a string to a vertex to create a graph in Java? Jung Java Graph如何在视图中设置顶点的ID - Jung Java Graph How to set ID on vertex in view 如何找到入射到特定顶点的边列表 - How to find the list of edges incident to a particular vertex 使用Java在顶点标签上的DSE图索引 - Dse graph indexing on vertex label using Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM