TNC A Simple Greedy Algorithm for Energy-Efficient Communication in Small Multi-Interface Wireless Networks

Wireless networks have become extremely popular recently due to the wide range of applications they support and also because sophisticated and affordable wireless devices like smartphones, tablets, etc have actually become part of our everyday life. Wireless devices have heterogeneous characteristics, like computational power, energy-consumption levels, supported communication protocols. Modern wireless devices are usually equipped with multiple radio interfaces like, WiFi, GPRS, Bluetooth, and can switch between different communication networks for meeting connectivity requirements and, thus improving quality of service and data collection perspectives. Establishing a connection between any two such devices requires that they are close and share at least one common available interface. If communication is established between two wireless devices, then the involved communication cost reflects the energy these devices consume and equals the cost for activating a particular common interface. In this setting, the objective is to suggest a cost-efficient interface activation plan which can guarantee low-cost communication for any two such wireless devices. We model this practical problem as an instance of the Spanning Tree problem in an appropriately defined multigraph corresponding to the actual multi-interface wireless network. When connectivity is feasible, we propose and experimentally evaluate a simple greedy algorithm indicating which interfaces must be activated so that cost-efficient connectivity is established between any two wireless devices in the network.


Introduction
Wireless networks have become extremely popular during the recent years mainly due to the wide range of applications they support and also due to the fact that sophisticated and affordable wireless devices like smartphones, tablets, etc have actually become part of our everyday life. Wireless networks can be stand-alone network components (like for example a wireless network for a class or lab) or parts of larger networks and the Internet. Wireless devices have heterogeneous characteristics: they have different computational power, their energy-consumption levels vary, they support different communication protocols. Modern wireless devices are usually equipped with multiple radio interfaces like, for example, variations of the problem are considered depending on the topology of the input graph (e.g., complete graphs, trees, planar graphs, bounded-degree graphs, general graphs) and on whether the number of interfaces is part of the input or a fixed constant. [6] considers both unit-cost interfaces and more general homogeneous instances. ConMI has been introduced in [7] which studies homogeneous instances of the problem. ConMI is proved to be APX-hard even when the graph modeling the network has a very special structure and the number of available interfaces is small (e.g., 2). In [7], a 2-approximation algorithm is presented by exploiting the relation of ConMI on homogeneous instances with the minimum spanning tree on an appropriately defined edge-weighted graph. Furthermore, [1] suggests an improved (3/2+ε)approximation algorithm for ConMI. The algorithm is based on a challenging technique [10] that makes use of an "almost" minimum spanning tree in an appropriately defined hypergraph and transforms it to an efficient solution for connectivity. Better approximation bounds are obtained for special cases of ConMI such as the case of unit-cost interfaces. [9] provides a comprehensive survey on results from the recent relevant literature.
In this work, we focus on the heterogeneous, bounded form of ConMI. We model this practical problem as an instance of finding a spanning tree in an appropriately defined multigraph corresponding to the actual multi-interface wireless network. When connectivity is feasible, we propose, analyze and experimentally evaluate a simple greedy algorithm which indicates which interfaces must be activated so that cost-efficient connectivity is established between any two wireless devices in the network. We embed this technique into a proof-of-concept application for establishing energy-efficient communication within small groups of users (in classrooms, labs, meeting rooms, game rooms, etc) equipped with wireless devices (e.g., smartphones or tablets) supporting multiple interfaces. From a practical point of view, network infrastructure and data collection perspectives can highly benefit from the efficient management of available interfaces in multi-interface wireless networks.
The rest of the paper is structured as follows. In Section 2, we provide technical details regarding definitions and notation. In Section 3, we discuss our greedy approach to the connectivity problem in multi-interface wireless networks. We present experimental finding in Section 4 and conclude our report in Section 5.

Preliminaries: Definitions and Notation
In general, a multi-interface wireless network is modelled by a graph G = (V, E), where V represents the set of devices composing the network and E is the set of possible connections defined according to the distance between devices and the available interfaces that they share. Each v∈V is associated with a set of available interfaces W(v). The set of all the possible available interfaces in the network is then determined by ∪v∈vW(v); we denote by k the cardinality of this set.
We say that a connection is established when the endpoint of the corresponding edge share at least one active interface. So, in our model, an edge es= (u,v)s exists for every interface s both u and v share, yielding a multigraph G which is assumed to be undirected and connected. If an interface s is activated at some node u, then u consumes some energy cu(s) for keeping s active and obtains a maximum communication bandwidth bu(s) with all its neighbors that share interface s. Furthermore, each possible edge (u,v)s has a cost equal to cu(s)+cv(s).
For globally characterizing the interfaces each device supports, we use an interface assignment function W which covers graph G = (V, E), i.e., for each (u,v)∈E it holds W(u) ∩ W(v) ≠ ∅. Our objective is to activate interfaces at the nodes of V so that the resulting graph G' is a spanning tree for G, i.e. G' is connected, acyclic and spans all nodes of V. In the case when the resulting spanning tree G' has a minimum total edgeweight, we have a Minimum Spanning Tree (MST) for G.
Two classical deterministic greedy algorithms for constructing Minimum Spanning Trees are due to Kruskal [8] and Prim [11]. Both algorithms proceed by successively adding edges of smallest weight from those edges with a specified property that have not already been used. The main difference is the criterion used to select the next edge or edges to be added in each step. They are particularly simple and in fact solve the same problem by applying the greedy approach in two different ways and both always yield an optimal solution.
Kruskal's algorithm starts with an edge in the graph with minimum weight and builds the spanning tree by successively adding edges one by one into a growing spanning tree. It processes the edges in order of their weight values, from smallest to largest, including into the growing MST each edge which does not form a cycle with edges previously added. It stops after |V|-1 edges have been added. Kruskal's algorithm computes the MST of any connected edge-weighted graph with E edges and V vertices in time proportional to |E|log|E| (in the worst case) since sorting is the most time consuming operation.
Prim's algorithm constructs a minimum spanning tree incrementally, in a step-by-step fashion via a sequence of expanding subtrees. The initial subtree of the sequence consists of a single vertex selected arbitrarily from the set V of the vertices of the given graph. In each successive step, the algorithm expands the current tree greedily by simply adding to it the nearest vertex not in the tree. The distance of such a vertex is determined by the weight of the edge connecting it to the tree. In the case of at least two candidate nearest vertices, ties can be broken arbitrarily. The algorithm terminates when all vertices of the graph have been included in the spanning tree. Since the algorithm expands a tree by exactly one vertex during each step, the total number of required steps is n-1, where n is the number of vertices of V. The tree generated by the algorithm is obtained as the set of edges used for the tree expansions.
More precisely, the algorithm maintains two disjoint sets of vertices: one containing vertices that are in the growing spanning tree and another containing vertices not in the growing spanning tree. Then, it selects the lowest-cost vertex which is connected to the growing spanning tree but is not in the growing spanning tree and inserts it into the growing spanning tree. In order to avoid the creation of cycles, the algorithm marks the vertices which have been already selected and considers only those vertices that are not marked. Since each vertex is considered only once, the time complexity of the Prim's algorithm is O((|V|+|E|)log|V|).

Description and analysis
GMU is a deterministic, greedy algorithm for connectivity in multi-interface wireless networks. It receives as input a graph G = (V,E) corresponding to a wireless network whose nodes support multiple interfaces. For each vertex v∈V (representing a network node), information regarding supported interfaces and corresponding activation cost is provided. Each edge es∈E connects pairs (u,v) of distinct vertices of V sharing interface s and has an associated weight equal to the sum of the activation cost of interface s at nodes u and v. Multiple edges are allowed between pairs of nodes sharing multiple (i.e., more than one) interfaces. If W(u) ∩ W(v) ≠ ∅ for all (u,v) ∈ E, the algorithm returns a spanning tree T = (VT, ET) for G, that is VT=VG, ET ⊆ EG.
More precisely, our algorithm works as follows. For a given input graph G = (V, E), the algorithm first checks whether there exists (u,v) ∈ E for which the condition W(u) ∩ W(v) ≠ ∅ is false. If so, the algorithm terminates and fails to compute a spanning tree for G. If W(u) ∩ W(v) ≠ ∅ is true for all (u,v) ∈ E, a vertex set VT is created and an arbitrary vertex v ∈ VG is added to it. Furthermore, a list L of edges is created where all edges (u,v) ∈ E with u ∈ VT and v ∈ V\VT are added. In this way, the formation of cycles in VT is avoided. L is sorted in ascending order in terms of edge-weights. Then, the main loop of the algorithm is repeated until VT=VG. At each round, the first element of L (i.e., the edge of L of minimum weight) is added to T and L is updated so as to only include edges whose one endpoint belongs to VT and the other is strictly in V\VT. Eventually, the algorithm terminates and returns a spanning tree T for G.
Below, the pseudocode for our greedy approach is presented. 6. Update L (add/remove elements, sort)

Lemma 1 (Correctness)
Algorithm GMU produces a spanning tree T for G=

Proof
If there exists (u,v) ∈ E for which W(u) ∩ W(v) = ∅, the algorithm terminates and fails to compute a spanning tree T for G (Step 1). Otherwise, a vertex v ∈VG is chosen uniformly at random and added to VT (Step 2). A list L is created containing all edges (u,v) ∈ EG such that u ∈ VT and v ∈ V\VT (Step 3). If |VG|=1, a (minimum) spanning tree T is returned with |VT|=|VG|=1 and the algorithm terminates (Step 7). Otherwise, the while loop is executed (Step 4).
In order to show that the returned graph is indeed a tree, we have to show that the resulted graph is connected and acyclic. Consider an instance after a while loop is executed and let {v1, v2, …, vn} ∈ VT, n < |VG| and {vn+1, …, v|VG|}∈ VG\VT. Assume that e=(vi, vj) is an edge currently considered for addition to T. This implies that one of the endpoints of e, say vi, must be in VT. Then, for a cycle to be created, vj must be a vertex already visited, i.e., a vertex also in VT. This is a contradiction since every edge e=(vi, vj) considered for addition to T must have vi∈ VT and vj ∈ V\VT (or vice-versa). Furthermore, T will eventually contain all nodes of G, since T is gradually augmented until VT=VG. This completes the proof of Lemma 1.

Proof
Assuming that the number of available interfaces is O(|V|), Step 1

Lemma 3 (Activation cost)
Algorithm GMU yields a total activation cost of O(V).

Proof
The spanning tree computed by algorithm GMU for an input graph G=(V,E) representing a wireless network whose nodes support multiple interfaces has |V-1| edges. Assuming that c is the maximum activation cost taken over all available interfaces yields a maximum total cost of O(V).

Software and hardware
For our experimental study, we used Python 3. We preferred Python to other popular programming languages, like C++ or Java, because it is friendly to use and easy to learn; yet, it is a powerful programming language which allows simple and flexible representations of networks as well as clear and concise expressions of network algorithms. Python can be used on many operating systems, providing a standard library and plenty of community-contributed modules. Python is developed under an open source license, making it freely usable and distributable [13]. Python 3, in particular, offers new important programming features and facilities as well as improved memory management.
Furthermore, we used NetworkX for our implementation. NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. NetworkX provides improved features regarding numerical linear algebra and drawing and can facilitate tasks including loading and storing networks in various data formats, generation of random and classic networks, analysis of network structure, building network models, drawing networks, and so on. NetworkX is freely usable and distributable under the terms of the 3-clause BSD License [12].
We implemented and executed our experiments on a mac OSX machine with an Intel Core i7 2,2 GHz processor and 16 GB 1333 MHz DDR3 RAM.

Input
The input multigraph corresponding to a wireless network supporting multiple interfaces can be provided to our code either manually or automatically.
Providing the input manually requires the use of NetworkΧ packages together with a basic program in Python. First, network nodes are defined. For each node a unique id and the interfaces it supports together with their activation cost must be given. Then, connections between nodes are defined in terms of graph edges. Multiple edges are allowed between each pair of network nodes; each edge corresponds to an interface shared by the nodes of the pair. For each edge, its endpoints and its weight must be given. The weight of an edge (u,v) corresponding to a shared interface s equals the sum of the activation cost of interface s at nodes u and v. Figure 1 shows an input instance provided manually.

Figure 1: Manual generation of an input instance.
Providing the input automatically requires the execution of the "graph generator" function depicted in Figure 2.    Our "graph generator" works as follows. Initially, the total number of graph vertices is randomly chosen via the use of function "random". Then, the input multigraph is generated by 4 consecutive "for" loops. The first "for" loop generates the vertices of the graph (attributing to each of them an id, supported interfaces and interface activation costs). The second "for" loop verifies that there exists at least one shared interface between each pair of vertices; if this is not the case, the "graph generator" terminates and restarts. The last two "for" loops are then used to generate the edges of the multigraph. The total number of edges is generated via the use of function "random". Endpoints are also randomly assigned to edges. Then, a verification process checks for edges having both endpoints assigned the same vertex. If no such edge exists, edge endpoints are checked for shared interfaces and the final input graph is produced.

Main part of the code
The core component of our code is presented in Figure 3, implements algorithm GMU and works as follows.
Initially, an arbitrary graph vertex is selected, assigned to variable ranV and printed on the screen. Then, a list L is created containing already explored vertices; ranV is inserted to L. Furthermore, a second list, namely sortEdges, is created containing edges to be considered for addition to the generated spanning tree; these are edges whose one endpoint is a vertex already explored (and, therefore, included in list L) and their other endpoint is a vertex not yet explored. The list sortEdges is sorted in ascending order of weight of included edges. The required spanning tree is then built through a main "while" loop. In particular, elements of the list sortEdges are printed on the screen, the edge emin of the minimum weight is assigned to variable ST (which corresponds to the spanning tree under generation) and the just explored endpoint of emin is also added to L. Then, the list sortEdges is updated. # # st on conMI # # randomly select a vertex ranV = random.randint(1,G.number_of_nodes()) print('Begin algorithm with randomly selected vertex:', ranV) # create list of visited nodes and append the randomly selected vertex l = [] l.append(ranV) # find edge with minimum weight sortEdges = sorted(G.edges([ranV],data='weight',keys=True),key=itemgetter (3) print('Edge',a,b,'has',c) print("\nTIME:",end-start) # initializing already activated attribute for SΤ nodes for n in ST.nodes(): ST       Christos Kaklamanis, Stavros Maras, Evi Papaioannou;A Simple Greedy Algorithm for Energy-Efficient Communication in Small Multi-Interface Wireless Networks , Transactions on Networks and Communications, Volume 6 No. 2, April (2018)  Each run is followed by the list of edges of the generated spanning tree, the total time (in seconds) required for the spanning tree generation, to total activation cost and the total cost for activating all available interfaces at all network nodes.

Experimental results
For our experimental analysis, a total of 30 automatically generated input instances have been used. Assuming the existence of 2 available interfaces, algorithm GMU has been used to compute spanning trees for these instances. Below, we first give an example of an automatically generated input instance; then, we provide charts for the performance of our approach in terms of activation cost and execution time.

An example of an automatically generated input instance
Below, we provide screen captures of an indicative experiment. A wireless network of 38 nodes is automatically generated; there are 2 available interfaces. Figure 5 shows network nodes. Edges are depicted in Figure 6.

Figure 6: Edges of an automatically generated input instance with 2 available interfaces
Algorithm GMU executed for the input instance presented above computed the spanning tree depicted in Figure 7.  Figure 8 shows how the network size affects the performance of our greedy approach in terms of total activation cost. Assuming that the input multigraph is connected, we compare the total activation cost induced by GMU to the cost of activating all available interfaces at all network nodes and, also, to O(|V|).

Activation cost
In terms of activation cost, GMU obtains a performance linear in the size of the network; this implies that an extremely simple greedy solution can offer a satisfactory performance as long as the network size remains limited. Indeed, small-scale wireless networks composed of devices supporting a small number of interfaces do appear often in school classes, labs, meeting rooms, medical councils, etc. In such cases, a simple greedy approach like GMU, although theoretically deemed to perform much worse than significantly more complex approaches from the recent literature, can suggest a useful practical solution.  Figure 9 shows how the network size affects the performance of our greedy approach in terms of execution time. Measurements were taken using the function "time" offered by Python. We measured the time interval needed to compute a spanning tree for an input graph G by algorithm GMU. As it can be observed, for networks composed of at most 100 nodes, the running time of GMU is less that 1 sec; for larger networks of approximately 500 nodes, the running time of GMU remains low (at most 1 min) in practice.

Conclusion
We addressed the problem of connectivity in small wireless networks composed of devices supporting multiple interfaces. From a practical point of view, network infrastructure and data collection perspectives can highly benefit from the efficient management of available interfaces in multi-interface wireless networks. We modelled this practical problem as an instance of the Spanning Tree problem in an appropriately defined multigraph corresponding to the actual multi-interface wireless network. We suggested a simple greedy algorithm that indicates which interfaces must be activated so that costefficient connectivity is established between any two wireless devices in the network. Our approach shows that simple solutions of theoretically poor performance can still be interesting in practice.
Our future plans include the implementation of the randomized polynomial-time approximation scheme of Prömel and Steger for solving almost exactly the MST problem in hypergraphs [10]; such an implementation would be extremely interesting as a stand-alone component but also as a building block of the (3/2+ε)-approximation algorithm presented in [1] for connectivity in multi-interface wireless networks.