1 /*
2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
13 * reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 *
20 *
21 * This file is almost a complete re-write for Open MPI compared to the
22 * original mpiJava package. Its license and copyright are listed below.
23 * See <path to ompi/mpi/java/README> for more information.
24 *
25 *
26 * Licensed under the Apache License, Version 2.0 (the "License");
27 * you may not use this file except in compliance with the License.
28 * You may obtain a copy of the License at
29 *
30 * http://www.apache.org/licenses/LICENSE-2.0
31 *
32 * Unless required by applicable law or agreed to in writing, software
33 * distributed under the License is distributed on an "AS IS" BASIS,
34 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 * See the License for the specific language governing permissions and
36 * limitations under the License.
37 *
38 *
39 * File : GraphParms.java
40 * Author : Xinying Li
41 * Created : Thu Apr 9 12:22:15 1998
42 * Revision : $Revision: 1.1 $
43 * Updated : $Date: 1998/08/26 18:49:55 $
44 * Copyright: Northeast Parallel Architectures Center
45 * at Syracuse University 1998
46 */
47
48 package mpi;
49
50 /**
51 * Graph topology information associated with a communicator.
52 */
53 public final class GraphParms
54 {
55 /** Node degrees. */
56 private final int[] index;
57
58 /** Graph edges. */
59 private final int[] edges;
60
61 /**
62 * Constructs a graph topology information object.
63 * @param index node degrees.
64 * @param edges graph edges.
65 */
66 protected GraphParms(int[] index, int[] edges)
67 {
68 this.index = index;
69 this.edges = edges;
70 }
71
72 /**
73 * Returns the number of nodes.
74 * @return number of nodes.
75 */
76 public int getIndexCount()
77 {
78 return index.length;
79 }
80
81 /**
82 * Returns the index of the node {@code i}.
83 * <p>{@code getIndex(0)} returns the degree of the node {@code 0}, and
84 * {@code getIndex(i)-getIndex(i-1)} is the degree of the node {@code i}.
85 * @param i position of the node.
86 * @return the index.
87 */
88 public int getIndex(int i)
89 {
90 return index[i];
91 }
92
93 /**
94 * Returns the number of edges.
95 * @return number of edges.
96 */
97 public int getEdgeCount()
98 {
99 return edges.length;
100 }
101
102 /**
103 * Returns the edge {@code i}.
104 * <p>The list of neighbors of node zero is stored in {@code getEdge(j)},
105 * for {@code 0} ≤ {@code j} ≤ {@code getIndex(0)-1} and the list
106 * of neighbors of node {@code i}, {@code i} > {@code 0}, is stored
107 * in {@code getEdge(j)}, {@code getIndex(i-1)} ≤ {@code j} ≤
108 * {@code getIndex(i)-1}.
109 * @param i index of the edge.
110 * @return the edge.
111 */
112 public int getEdge(int i)
113 {
114 return edges[i];
115 }
116
117 } // GraphParms