Abstract. Motivated by the need for agent classification in sensor networking and autonomous vehicle control applications, we propose a flexible and distributed stochastic automaton-based network partitioning algorithm that is capable of finding the optimal k-way partition with respect to a broad range of cost functions, and given various constraints, in directed and weighted graphs. Specifically, we motivate the need for new algorithms for network partitioning and distributed (or self-) partitioning. We then review our stochastic automaton-based partitioning algorithm, and extend its use for network partitioning and self-partitioning problems. Finally, the application of the algorithm to mobile/sensor classification in ad hoc networks is pursued in detail, and other applications are briefly introduced.