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 (c) 2018 FUJITSU LIMITED. All rights reserved.
15 * $COPYRIGHT$
16 *
17 * Additional copyrights may follow
18 *
19 * $HEADER$
20 */
21
22 package mpi;
23
24 /**
25 * Adjacency information for a distributed graph topology.
26 */
27 public final class DistGraphNeighbors
28 {
29 private final int[] sources, sourceWeights, destinations, destWeights;
30 private final boolean weighted;
31
32 protected DistGraphNeighbors(
33 int[] sources, int[] sourceWeights,
34 int[] destinations, int[] destWeights, boolean weighted)
35 {
36 this.sources = sources;
37 this.sourceWeights = sourceWeights;
38 this.destinations = destinations;
39 this.destWeights = destWeights;
40 this.weighted = weighted;
41 }
42
43 /**
44 * Gets the number of edges into this process.
45 * @return number of edges into this process
46 */
47 public int getInDegree()
48 {
49 return sources.length;
50 }
51
52 /**
53 * Gets the number of edges out of this process.
54 * @return number of edges out of this process
55 */
56 public int getOutDegree()
57 {
58 return destinations.length;
59 }
60
61 /**
62 * Returns false if {@code MPI_UNWEIGHTED} was supplied during creation.
63 * @return false if {@code MPI_UNWEIGHTED} was supplied, true otherwise
64 */
65 public boolean isWeighted()
66 {
67 return weighted;
68 }
69
70 /**
71 * Gets a process for which the calling process is a destination.
72 * @param i source index
73 * @return process for which the calling process is a destination
74 */
75 public int getSource(int i)
76 {
77 return sources[i];
78 }
79
80 /**
81 * Gets the weight of an edge into the calling process.
82 * @param i source index
83 * @return weight of the edge into the calling process
84 */
85 public int getSourceWeight(int i)
86 {
87 return sourceWeights[i];
88 }
89
90 /**
91 * Gets a process for which the calling process is a source
92 * @param i destination index
93 * @return process for which the calling process is a source
94 */
95 public int getDestination(int i)
96 {
97 return destinations[i];
98 }
99
100 /**
101 * Gets the weight of an edge out of the calling process.
102 * @param i destination index
103 * @return weight of an edge out of the calling process
104 */
105 public int getDestinationWeight(int i)
106 {
107 return destWeights[i];
108 }
109
110 } // DistGraphNeighbors