You are on page 1of 5

Algorithm to Count the Number of Signed Paths in an Electrical Network via Boolean Formulas

Guillermo De Ita, Helena G mez, Belem Merino o Benem rita Universidad Aut noma de Puebla, M xico e o e Email: deita@solarium.cs.buap.mx, helena.adorno@gmail.com, poxbelem@hotmail.com

AbstractThis article presents a practical method to count the different signed paths to maintain charge on each of the lines of energy of an electrical network. We assume a charge on each network node. We model this problem via the #2SAT problem. #2SAT consists on counting models of boolean formulas, where the input Boolean formula is in 2 conjunctive form. To develop this method we rely on the connectivity graph of an electrical network from which we get its boolean formula and apply recurrence equations starting from the terminal nodes up to the root node of the network. The recurrence equations allows to carry the count to indicate the different ways to keep charge on all line of the electrical network. Keywords-#SAT Problem; Counting models; Electrical Network; Graph tree;

structure of the undirected graph induced by the restrictions (clauses) of the formula. We start considering signed graphs (graphs whose edges are designated positive or negative). That class of graphs have been very useful for modeling different class of problems in the social sciences [6], [7], [8]. For example the signed graphs are used for modeling the interaction among a group of persons and the type of relationship between certain pair of individuals of the group. We consider here an extension of the signed graphs where all edge in the graph has associated a pair of signs. In this way, any binary clause can be represented by such signed edges. And we model an electric network by those extended signed graphs. We are interested in computing the different assignments associated to the variables (nodes) in the network which produces that all edge in the network will be satised by at least one of its two possible signs. The aim is to develop a method to count the different signed paths in which an electric network held energy on each of its electric lines, by counting the number of models in the Boolean formula associated to the network. II. M ETHODOLOGY Below we summarize a basic set of concepts through which we try to improve a more complete understanding of terms that will be used in this work. Topology: Systematic study of the components of an electrical network and its reciprocal links [2]. Element: Individual constituent of a network with two or more terminals or bounds that are used for interconnection with other elements [2]. Nodes and branches: The junction points of the elements in a network are called nodes. Several elements

I. I NTRODUCTION The problem of propositional satisf iability (SAT ) is a classic NP-complete problem, but there is a wide range of research on how to identify limited instances for which the SAT problem can be solved efciently. The problem of counting models of a boolean formula (#SAT ) is relevant for approximating reasoning processes tasks. For example, for estimating the degree of reliability in a communication network,computing degree of belief in propositional theories, for the generation of explanations to propositional queries, in Bayesian inference, in a truth maintenance systems and for repairing inconsistent databases [3], [4], [5], [9], [10]. Those previous problems come from several AI applications such as planning, expert systems, reasoning, etc. #SAT is as difcult as the SAT problem, but even when SAT can be solved in polynomial time, is not known an efcient computational method for #SAT . For example, the 2-SAT problem (SAT limited to consider ( 2)-CFs it can be solved in linear time, however, the corresponding counting problem #2-SAT is a #P-complete Problem. The maximum polynomial class recognized for #2SAT is the class ( 2, 2)-CF (conjunction of binary or unary clauses where each variable appears twice at most) [5], [9]. Here, we extend such class for considering the topological

can join together and considered as a single unit or a whole. When several elements are joined together so that the ow is the same in all of them are said to be connected in series. The junctions between components are called internal nodes. The pair of external nodes is the nodes themselves or simply nodes. The set of elements in series between the nodes themselves are called branches [2]. Graph: It is the geometric, topological, representation of a network, forming a backbone of the physical layout of the network [2]. A graph G is represented by a pair (V, E) where V is the set of nodes and E the set of edges. A signed graph (also called sigraph) is an ordered pair = (G, ) where G = (V, E) is a graph called the underlying graph of and : E {+, } is a function called a signature or signing. E + () denotes the set of edges from E that are mapped by to +, and E () denotes the set of edges from E that are mapped by to -. The elements of E + () are called positive edges and those of E () are called negative edges of . A signed graph is all-positive (respectively, all-negative)if all of its edges are positive (negative); further, it is said to be homogeneous if it is either all-positive or all-negative, and heterogeneous otherwise. For example the signed graphs are used for modeling the interaction among a group of persons and the type of relationship between certain pair of individuals of the group. Special focus is on the social inequalities. What is it about such characteristics as sex, race, occupation, education, and so on that leads to inequalities in social interaction? [8]. Given a set of de n Boolean variables, X = {x1 , x2 , ..., xn }. Its called a literal to any x variable or the negation of it x. We use v(l) to indicate the variable involved by the literal l. The disjunction of different literals is called a clause. For k N, a k clause is a clause consisting of exactly k literals. A variable x X appears in a clause c if x or x is an element of c. Let v(c) = {x X : x appears in c}. A conjunctive form (CF ) is a conjunction of clauses. A k CF is a CF containing only k clausulas and, ( k) CF denotes a CF containing clauses with at most k literals. Let be a 2-CF, then an assignment s for is a function s : v() {0, 1}. An assignment can also be considered as a set of non-complementary pairs of literals. If l s, being s an assignment, then s makes l true and makes l f alse. A clausula c is satisf ied if and only if c s = ,

and if for all l c, l s then s falsies c. A CF is satisable by an assignment s if each clausula in is satisable by s and is contradicted if it is not satised. s is a model of if s is a satised assignment of . Let SAT () be the set of models than has over v(). is a contradiction or unsatisable if SAT () = . Let v() () = |SAT ()|, be the cardinality of SAT (). Given a CF , the SAT problem consists in determining if has a model. The #SAT consists of counting the number of models of F dened over v(). We will also denote v() () by #SAT () [1]. Given a signed network G , we obtain the associated Boolean formula , this formula can be expressed as a two Conjunctive Form (2 CF ) in the following way. Let G = ((V, E), ) be the signed network, then where v() = V and for all positive edge {x, y} in the network the clause (v(x), v(y)) is formed in , while for a negative edge {x, y} the clause (v(x), v(y)) is formed in . This means that the vertices of G are the variables of , and for each clause (x, y) in there is a signed edge (v(x), v(y)) E. III. B UILDING R ECURRENCE E QUATIONS FOR C OUNTING S IGNED PATHS IN AN E LECTRICAL N ETWORK The signed graphs are very useful to represent some kind of relationships among individuals. In this case, each person is a node of the graph and there is an arc between {x, y} if x is in some relation to y. Many of the relationships of interest have natural opposites, for example: likes/dislikes, associates with/avoids, and so on [8]. For this, two different signs {+, } are associated with each edge of the graph. For example, if we consider that x likes y, then a positive edge is denoted between x and y, but we do not know what about y with x. y might dislike x or maybe like him. In order to be more precise in the kind of relationships between two individuals is better to consider two signs in each edge, one sign associated with each point end of the edge. Furthermore, in order to consider general Boolean formulas in 2-CF, we consider an extension of the concept of signed graphs. Instead to consider just one sign (+ or -) associated with each edge of a signed graph G = ((V, E), ), we consider here that all edge in E has associated a pair of signs. Then the signed function has now the type : {(+, +), (+, ), (, +), (, )} which gives a pair of signs to each edge of G.

In this way, all binary clause {x, y} can be represented by a signed edge in the graph in a natural way without importance of the signs associated to the variables in the clause. For example the clause {x, y} will be represented as the signed edge x y and in this case, - is called the adjacent sign of x and + the adjacent sign of y in the edge x y. Add more, we can consider those extended signed graphs as electric networks. = (G, ) where G = (V, E) is the underlying graph of and : E {(+, +), (+, ), (, +), (, )} is the signature function. That means that all edge in the network is energized in its endpoints. We are interested here, in count the different assignments associated to the nodes of the network in such a way that all edge in the network will be satised by at least one of its two possible signs of its endpoints. For this, we start analyzing the way to build satisfy assignment in the network considering rst the most simple topologies associated with the underlying graph of the electrical networks. A. If the Electrical Network is a Linear Path Let us consider that the electrical network, G = (V, E) is a linear path. Let us write down its associated formula , without a loss of generality (ordering the clauses and its literals, if it were necessary), as: = m {c1 , ..., cm } = {x11 , x1 }, {x22 , x2 }, . . . , {xm1 , xm } , m 2 3 where |(ci ) (ci+1 )| = 1, i [[m 1]], and i , i {0, 1}, i = 1, ..., m. In order to compute the number of signed paths in such electrical network, we start with a pair of values (i , i ) associated with each node i of the network. We call the charge of node i to the pair (i , i ). The value (i ) indicates the number of times that node i takes the positive value and (i ) indicate the number of times that node i takes the negative value. Let fi be a family of clauses of built as follows: f0 = ,fi = {cj }ji , i [[m]]. Note that fi fi+1 , i [[m 1]]. Let SAT (fi ) = {s : s satisf ies fi }, Ai = {s SAT (fi ) : xi s}, Bi = {s SAT (fi ) : xi s}. Let i = |Ai |; i = |Bi | and i = |SAT (fi )| = i + i . From the total number of models in i , i [[m]], there are i of which xi takes the logical value true and i models where xi takes the logical value false. For example, c1 = (x11 , x1 ), f1 = {c1 }, and 2 (1 , 1 ) = (1, 1) since x1 can take one logical value
+ +

true and one logical value false and with whichever of those values satises the subformula f0 while 1 SAT (f1 ) = {x11 x1 , x1 1 x1 , x11 x2 1 }, and then 2 1 2 (2 , 2 ) = (2, 1) if 1 were 1 or rather (2 , 2 ) = (1, 2) if 1 were 0. In general, we compute the values for (i , i ) associated to each node xi , i = 2, .., m, according to the signs ( i , i ) of the literals in the clause ci , by the next recurrence equation:
,i1 + i1 ) (i1 (i1 + i1 ,i1 ) (i , i ) = ,i1 + i1 ) (i1 (i1 + i1 ,i1 ) if ( if ( if ( if ( = (, ) = (, +) i , i ) = (+, ) i , i ) = (+, +)
i , i ) i , i )

(1)

We denote with the application of one of the four rules of the recurrence (1), so, the expression (2, 3) (5, 2) denotes the application of one of the rules (in this case, the rule 4), over the pair (i1 , i1 ) = (2, 3) in order to obtain (i , i ) = (i1 + i1 , i1 ) = (5, 3). In recurrence ( 1) the ( i , i ) represents the signs associated with the edge joining a child node joining with the father node. These recurrence equations allow to carry the count to indicate the different ways to keep the electrical network powered. In fact, the sum i + i obtained from the root node of the network, indicate the total number of Boolean formula models associated with the network and it is as well as the number of different ways to keep the charge on all electric line in the electrical network.
a) +
x1

+
x2 (2,1)

x3 (2,3)

+
x4 (5,3)

+
x5 (8,5) =13 models

(1,1)

b)
x1

+
x2 (2,1)

x3 (1,3)

+
x4 (4,1)

+
x5 (5,1) =6 models

(1,1)

Figure 1. a) Counting models over a positive electrical path network b) Counting models over a general electrical path network

Example 1: Let = {(x1 , x2 ), (x2 , x3 ), (x3 , x4 ), (x4 , x5 )} be a path, the series (i , i ), i [[5]], is computed according to the signs of each clause, as it is illustrated if the gure (1a). A similar path with 5 nodes but with different signs in the edges is shown in gure (1b).

Example 2: Let = {(x1 , x2 ), (x2 , x3 ), (x3 , x4 ), (x4 , x5 ), (x5 , x6 )} be a 2-CF which conforms a linear path, the series (i , i ), i [[6]], is computed as: (1 , 1 ) = (1, 1) (2 , 2 ) = (2, 1) since ( 1 , 1 ) = (1, 1), and the rule 4 has to be applied. In general, applying the corresponding rule of the recurrence (1) according to the signs expressed by ( i , i ), i = 3, ..., 6, we have (2, 1) (3 , 3 ) = (1, 3) (4 , 4 ) = (3, 4) (5 , 5 ) = (3, 7) (6 , 6 ) = (10, 7), and then, #SAT () = () = 6 = 6 + 6 = 10 + 7 = 17. If is a path , we apply (1) in order to compute (). The procedure has a linear time complexity over the number of variables of , since (1) is applied while we are traversing the chain, from the initial node y0 to the nal node ym .
Figure 2. The tree graph for the formula of the example 1

B. If the Electrical Network is a Tree The charge of the nodes (i , i ) for i = 1...n, are calculated as the nodes are visited applying a post-order traversals. The rst pair of values (i , i ) for the terminal nodes of the network (tree leaves) are initialized with the value (1, 1). So, to traverse the tree in post-order, we start by the left tree rst, followed by the right tree, and then nally the root node. At each visit of a child node i 1 to a father node i, the new values (i , i ) are computed for the father node from the following formula [1]: Algorithm Count Models ( A ) Input: A the tree dened by the depth-search over connectivity graph of the electrical network G Output: The number of signed paths of an electrical network. Procedure: Traversing A in depth-st, and when a node v A is left (all of its edges have been processed) assign: 1. (v , v ) = (1, 1), If v is a leaf node in A 2. If v is a father node with a list of child nodes associated, i.e., u1 , u1 , ...uk , are the child nodes of v, then as we have already visited all the child nodes, then each pair (uj , uj ) j = 1, ..., k has been dened based on (1), (vi , vi ) is obtained by apply (2) over (i1 , i1 ) = (uj , uj ). This step is iterated until computes all the values (vj , vj ), j=1 j=1 j = 1, , k. And nally, let v = k vj y v = k vj 3. If v is the root node of A the return (v + v )

This procedure returns the number of signed paths for an electrical network in time O(n + m) which is the necessary time for traversing G in depth-rst. Example 3: Let = {(x1 , x2 ), (x2 , x3 ), (x2 , x4 ), (x2 , x5 ), (x4 , x6 ), (x6 , x7 ), (x6 , x8 )} be a 2 CF , obtained from connectivity graph of an electrical network and consider us that the depth-search starts in the node x1 . The tree generated by the depth-search as well as the number of signed paths in each level of the tree is showed in Figure 2. The procedure Count M odels returns for x1 = 168, x1 = 84 and the total number of signed paths is #SAT() = 168 + 84 = 252. IV. C ONCLUSION We show that the problem of counting the number of models of a Boolean formula can be applied to count the number of signed paths in an electrical network and that the complexity of the algorithm is linear time on the length of the network nodes. We also have presented different linear procedures to compute the number of energized paths in an electrical network, based on the formula in 2-CF, obtained from the graph of the electric network. And we will continue working on different applications and repercussions than might have this research in the future. R EFERENCES
[1] De Ita G., Bello P. y Contreras M. New Polynomial Classes for #2SAT Established Via Graph-Topological Structure, Engeneering Letters (2007). Available from
www.engineeringletters.com/issues v15/issue 2/EL 15 2 11.pdf

[2] L pina M., Rodrguez C. Ecuaciones de redes Topologa, Facultad o de Ingenieria - Universidad de Buenos Aires (1994). Available from http://materias..uba.ar/6509/Ecuaciones%20de%20Redes%20I%20al %2006-05-07.pdf [3] Angelsmark O., Jonsson P., Improved Algorithms for Counting Solutions in Constraint Satisfaction Problems, In ICCP: Int. Conf. on Constraint Programming, 2003. [4] Darwiche, A., On the Tractability of Counting Theory Models and its Application to Belief Revision and Truth Maintenance, Jour. of Applied Non-classical Logics, pp. 11-34, N11(1-2),2001. [5] De Ita G., Polynomial Classes of Boolean Formulas for Computing the Degree of Belief, Advances in Articial Intelligence LNAI 3315,pp.430-440,2004. [6] Germina K.A., Hameed S.K., On signed paths, signed cycles and their energies, Applied Mathematical Sciences, Vol. 4:(70), 2010, pp. 34553466. [7] Kota P. S., Subramanya M.S., Note on path signed graphs, Notes on Number Theory and Discrete Mathematics 15:(4), 2009, pp. 1-6 [8] Fred S. Roberts, Graph Theory and Its Applications to Problems of Society, Edit. SIAM Collection, 1978. [9] Roth, D., On the hardness of approximate reasoning, Articial Intelligence 82,pp 273-302,1996. [10] Vadhan, S. P., The complexity of Counting in Sparse, Regular, and Planar Graphs, SIAM Journal on Computing,pp. 398-427, V31, N2, 2001.

You might also like